:root {
  color-scheme: light;
  --ink: #17233b;
  --muted: #667085;
  --line: #dde3ed;
  --soft: #f5f7fb;
  --panel: #ffffff;
  --navy: #152a4a;
  --blue: #3454d1;
  --blue-soft: #eef1ff;
  --cyan: #16a3b6;
  --green: #13966d;
  --green-soft: #eaf8f3;
  --amber: #e89822;
  --red: #df4c5b;
  --purple: #8a5bd4;
  --shadow: 0 12px 38px rgba(34, 49, 82, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1180px;
  color: var(--ink);
  background: #edf1f7;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid #dfe5ef;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: linear-gradient(145deg, #2947c7, #17a6b7);
  box-shadow: 0 8px 20px rgba(52, 84, 209, 0.25);
  font-size: 23px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.06em;
  font-size: 16px;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions,
.canvas-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.example-picker {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

select,
input[type="number"],
input[type="text"] {
  min-height: 38px;
  border: 1px solid #d5dce7;
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--ink);
}

select {
  padding: 0 34px 0 11px;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 0 10px;
}

select:focus,
input:focus {
  border-color: #8092e5;
  box-shadow: 0 0 0 3px rgba(52, 84, 209, 0.1);
}

.button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}

.button.primary {
  color: white;
  background: var(--blue);
  box-shadow: 0 7px 18px rgba(52, 84, 209, 0.25);
}

.button.primary:hover {
  background: #2947c7;
}

.button.ghost {
  border-color: #d8dfeb;
  background: white;
}

.button.small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 12px;
}

.button.danger {
  border-color: #f2c5ca;
  color: #b82d3c;
  background: #fff5f6;
}

.solve-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

kbd {
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.11);
  font: 11px ui-monospace, monospace;
}

.workspace {
  display: grid;
  min-height: calc(100vh - 76px);
  grid-template-columns: 104px minmax(760px, 1fr) 328px;
}

.tool-rail {
  position: sticky;
  top: 76px;
  align-self: start;
  display: flex;
  height: calc(100vh - 76px);
  flex-direction: column;
  gap: 6px;
  padding: 18px 11px;
  border-right: 1px solid var(--line);
  background: #f8f9fc;
}

.tool {
  display: flex;
  min-height: 66px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  color: #68748a;
  background: transparent;
  font-size: 10.5px;
  font-weight: 650;
}

.tool:hover {
  color: var(--blue);
  background: #f0f3fc;
}

.tool.active {
  border-color: #ced7f8;
  color: var(--blue);
  background: var(--blue-soft);
}

.tool-icon {
  display: block;
  height: 25px;
  font-size: 22px;
  font-weight: 750;
  line-height: 25px;
}

.tool-icon.thin {
  font-weight: 400;
}

.model-area {
  min-width: 0;
  padding: 20px;
}

.canvas-card,
.results {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.canvas-head,
.results-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px 13px;
}

.eyebrow {
  color: #7a879b;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

.canvas-head h1,
.results-title-row h2,
.inspector-head h2 {
  margin: 3px 0 0;
  font-size: 18px;
}

.snap-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.units-pill,
.method-pill {
  padding: 7px 10px;
  border-radius: 999px;
  color: #44516a;
  background: #f1f4f8;
  font-size: 11px;
  font-weight: 750;
}

.canvas-wrap {
  position: relative;
  margin: 0 14px;
  overflow: hidden;
  border: 1px solid #e2e7ef;
  border-radius: 13px;
  background: #fbfcfe;
}

#modelSvg {
  display: block;
  width: 100%;
  height: min(60vh, 620px);
  min-height: 470px;
  touch-action: none;
  user-select: none;
}

.canvas-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  max-width: 70%;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid rgba(203, 211, 225, 0.9);
  border-radius: 9px;
  color: #617087;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 5px 18px rgba(35, 48, 75, 0.08);
  font-size: 11px;
  pointer-events: none;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 14px;
  color: var(--muted);
  font-size: 11px;
}

.status-ok {
  color: var(--green);
  font-weight: 750;
}

.status-error {
  color: var(--red);
}

.inspector {
  position: sticky;
  top: 76px;
  align-self: start;
  min-height: calc(100vh - 76px);
  border-left: 1px solid var(--line);
  background: #f9fafc;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 20px 15px;
  border-bottom: 1px solid var(--line);
}

.inspector-head h2 {
  font-size: 16px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid #e2c7cb;
  border-radius: 9px;
  cursor: pointer;
  color: #b83d49;
  background: #fff5f6;
}

.inspector-body {
  max-height: calc(100vh - 285px);
  overflow: auto;
  padding: 18px 20px;
}

.inspector-placeholder {
  display: grid;
  min-height: 240px;
  place-items: center;
  align-content: center;
  color: #7c8798;
  text-align: center;
}

.placeholder-icon {
  margin-bottom: 10px;
  color: #a7b1c3;
  font-size: 30px;
}

.inspector-placeholder p {
  max-width: 210px;
  line-height: 1.55;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  color: #59667b;
  font-size: 11px;
  font-weight: 700;
}

.field em {
  color: #98a2b3;
  font-style: normal;
  font-weight: 500;
}

.section-label {
  margin: 20px 0 9px;
  padding-top: 15px;
  border-top: 1px solid #e3e8f0;
  color: #69768c;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: #536078;
  font-size: 12px;
}

.load-item {
  position: relative;
  margin-bottom: 8px;
  padding: 10px 34px 10px 11px;
  border: 1px solid #dfe5ee;
  border-radius: 9px;
  color: #4d5a70;
  background: white;
  font-size: 11px;
  line-height: 1.45;
}

.load-item button {
  position: absolute;
  top: 8px;
  right: 7px;
  border: 0;
  cursor: pointer;
  color: #b8424f;
  background: transparent;
}

.inline-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.convention-card {
  margin: 0 18px 18px;
  padding: 13px;
  border: 1px solid #dfe5ee;
  border-radius: 11px;
  color: #5a667a;
  background: white;
  font-size: 11px;
}

.convention-card strong {
  display: block;
  margin-bottom: 9px;
  color: #35425a;
  font-size: 11px;
}

.convention-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.swatch {
  width: 17px;
  height: 3px;
  border-radius: 3px;
}

.swatch.n {
  background: var(--purple);
}

.swatch.v {
  background: var(--green);
}

.swatch.m {
  background: var(--blue);
}

.results {
  min-height: 210px;
  margin-top: 18px;
}

.results-empty {
  display: flex;
  min-height: 210px;
  align-items: center;
  justify-content: center;
  gap: 25px;
  padding: 30px;
}

.results-empty h2 {
  margin-bottom: 7px;
  font-size: 17px;
}

.results-empty p {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.empty-graphic {
  display: flex;
  width: 90px;
  height: 70px;
  align-items: end;
  gap: 7px;
  padding: 10px;
  border-radius: 15px;
  background: var(--blue-soft);
}

.empty-graphic span {
  width: 18px;
  border-radius: 5px 5px 2px 2px;
  background: #91a2ee;
}

.empty-graphic span:nth-child(1) {
  height: 28px;
}

.empty-graphic span:nth-child(2) {
  height: 48px;
  background: var(--blue);
}

.empty-graphic span:nth-child(3) {
  height: 38px;
  background: var(--cyan);
}

.summary-grid {
  display: grid;
  padding: 0 20px 18px;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.summary-card {
  padding: 13px 14px;
  border: 1px solid #e0e6ef;
  border-radius: 11px;
  background: #fbfcfe;
}

.summary-card span,
.summary-card strong {
  display: block;
}

.summary-card span {
  margin-bottom: 5px;
  color: #778398;
  font-size: 10px;
  font-weight: 700;
}

.summary-card strong {
  color: #27354d;
  font-size: 16px;
}

.result-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.result-tab {
  padding: 11px 13px;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: #6c788c;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.result-tab.active {
  border-bottom-color: var(--blue);
  color: var(--blue);
}

.result-panel {
  display: none;
  padding: 18px 20px 24px;
}

.result-panel.active {
  display: block;
}

.result-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
}

.result-card {
  overflow: hidden;
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  background: white;
}

.result-card h3 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid #e4e9f0;
  background: #f8fafd;
  font-size: 12px;
}

.result-card-body {
  padding: 13px 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e8ecf2;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

th {
  color: #6c788b;
  background: #fafbfc;
  font-weight: 750;
}

th:first-child,
td:first-child {
  text-align: left;
}

tr:last-child td {
  border-bottom: 0;
}

.equilibrium-line {
  margin: 8px 0;
  padding: 9px 11px;
  border-radius: 8px;
  color: #34425a;
  background: #f4f6fa;
  font: 12px ui-monospace, "Cascadia Code", monospace;
}

.check-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 10px;
  font-weight: 800;
}

.equation-element {
  margin-bottom: 11px;
  border: 1px solid #dfe5ee;
  border-radius: 11px;
  background: white;
}

.equation-element summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.equation-body {
  padding: 0 14px 13px;
}

.interval {
  margin-top: 8px;
  padding: 10px 11px;
  border-left: 3px solid #91a2ee;
  border-radius: 3px 8px 8px 3px;
  background: #f7f8fc;
}

.interval strong {
  display: block;
  margin-bottom: 7px;
  color: #59677d;
  font-size: 10px;
}

.formula {
  margin: 5px 0;
  color: #263650;
  font: 12px ui-monospace, "Cascadia Code", monospace;
}

.diagram-stack {
  display: grid;
  gap: 13px;
}

.diagram-card {
  overflow: hidden;
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  background: white;
}

.diagram-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid #e5e9f0;
  font-size: 11px;
  font-weight: 750;
}

.diagram-head span:last-child {
  color: #7b879a;
  font-weight: 600;
}

.diagram-svg {
  display: block;
  width: 100%;
  height: 310px;
  background: #fbfcfe;
}

.warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #f0d4a6;
  border-radius: 9px;
  color: #8a5b16;
  background: #fff8ec;
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  max-width: 380px;
  transform: translateY(25px);
  padding: 12px 15px;
  border-radius: 10px;
  opacity: 0;
  color: white;
  background: #263650;
  box-shadow: 0 14px 36px rgba(22, 34, 56, 0.25);
  font-size: 12px;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: #b93343;
}

/* SVG model */
.grid-line {
  stroke: #e9edf4;
  stroke-width: 1;
}

.axis-line {
  stroke: #cdd5e1;
  stroke-width: 1.2;
}

.member {
  cursor: pointer;
  stroke: var(--navy);
  stroke-linecap: round;
  stroke-width: 7;
}

.member.truss {
  stroke: #3f78a8;
  stroke-dasharray: 12 6;
  stroke-width: 4;
}

.member-hit {
  cursor: pointer;
  stroke: transparent;
  stroke-width: 22;
}

.member.selected {
  stroke: var(--blue);
  filter: drop-shadow(0 0 4px rgba(52, 84, 209, 0.25));
}

.node {
  cursor: grab;
  fill: white;
  stroke: var(--navy);
  stroke-width: 3;
}

.node.selected {
  fill: var(--blue-soft);
  stroke: var(--blue);
  stroke-width: 4;
}

.node-label,
.member-label,
.dimension-label,
.load-label {
  paint-order: stroke;
  stroke: white;
  stroke-linejoin: round;
  stroke-width: 4px;
  fill: #263650;
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
}

.member-label {
  fill: #647188;
  font-size: 11px;
  font-weight: 700;
}

.support-shape {
  fill: #f4f6fa;
  stroke: #34425a;
  stroke-width: 2;
}

.support-ground {
  stroke: #637086;
  stroke-width: 2;
}

.load-arrow {
  stroke: var(--red);
  stroke-linecap: round;
  stroke-width: 2.5;
}

.load-label {
  fill: #c43545;
  font-size: 11px;
}

.release {
  fill: white;
  stroke: var(--navy);
  stroke-width: 2;
}

@media (max-height: 760px) {
  #modelSvg {
    min-height: 420px;
    height: 53vh;
  }
}
