:root {
  --bg: #ece5d7;
  --surface: rgba(255, 251, 245, 0.86);
  --surface-strong: #fffdf8;
  --surface-dark: #22251f;
  --ink: #1f221d;
  --muted: #66695e;
  --line: rgba(31, 34, 29, 0.12);
  --accent: #b85d2d;
  --accent-dark: #8e4319;
  --support: #2d5d50;
  --support-soft: #d8e7df;
  --danger: #7d2e18;
  --danger-soft: #f5ddcf;
  --shadow: 0 24px 60px rgba(57, 39, 18, 0.12);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --display: "Avenir Next Condensed", "Franklin Gothic Medium", "Arial Narrow", sans-serif;
  --body: "Avenir Next", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(184, 93, 45, 0.16), transparent 24%),
    radial-gradient(circle at top right, rgba(45, 93, 80, 0.14), transparent 20%),
    linear-gradient(180deg, #f7f1e5 0%, #efe6d6 46%, #e6dbc9 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(31, 34, 29, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 34, 29, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 50px;
}

.panel {
  border: 1px solid rgba(31, 34, 29, 0.1);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.app-header,
.workspace-grid,
.results-grid,
.panel-heading,
.panel-header,
.section-row,
.form-actions,
.summary-cards {
  display: grid;
  gap: 16px;
}

.app-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 22px 24px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff9f2;
  font-family: var(--display);
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.brand-text h1,
.brand-text p,
.panel-header h2,
.panel-header p,
.section-row h3,
.section-row p,
.panel-heading h3,
.panel-heading p,
.header-note strong,
.header-note span {
  margin: 0;
}

.brand-text h1 {
  font-family: var(--display);
  font-size: 2rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.brand-text p,
.panel-header p,
.section-row p,
.panel-heading p,
.header-note span {
  color: var(--muted);
}

.header-tools {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.header-note {
  display: grid;
  justify-items: end;
  gap: 4px;
  text-align: right;
}

.lang-switch {
  display: inline-flex;
  gap: 10px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(31, 34, 29, 0.1);
}

.lang-link,
.solid-button,
.secondary-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.lang-link {
  min-height: 38px;
  color: var(--ink);
}

.lang-link.active,
.solid-button {
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  color: #fff9f2;
  box-shadow: 0 14px 28px rgba(142, 67, 25, 0.22);
}

.secondary-button,
.mini-button {
  border-color: rgba(31, 34, 29, 0.14);
  background: rgba(255, 255, 255, 0.64);
  color: var(--ink);
}

.lang-link:hover,
.solid-button:hover,
.secondary-button:hover,
.mini-button:hover {
  transform: translateY(-1px);
}

.workspace-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  margin-top: 24px;
  align-items: start;
}

.form-panel,
.summary-panel,
.result-panel,
.saved-panel {
  padding: 24px;
}

.panel-header h2 {
  font-family: var(--display);
  font-size: 2.2rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-section + .form-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.section-row {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.section-row h3,
.note-block h3,
.panel-heading h3 {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.field-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(31, 34, 29, 0.14);
  background: var(--surface-strong);
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(184, 93, 45, 0.18);
  border-color: rgba(184, 93, 45, 0.5);
}

.form-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 24px;
}

.summary-panel {
  position: sticky;
  top: 18px;
  background:
    linear-gradient(180deg, rgba(34, 37, 31, 0.96), rgba(34, 37, 31, 0.92)),
    linear-gradient(140deg, rgba(45, 93, 80, 0.18), transparent 52%);
  color: #fff9f2;
}

.summary-panel .panel-header p,
.summary-panel .note-list {
  color: #e8dacd;
}

.summary-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.summary-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 249, 242, 0.08);
}

.summary-card span {
  display: block;
  color: #e8dacd;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: 1.75rem;
  line-height: 1;
}

.note-block {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 249, 242, 0.16);
}

.note-block h3 {
  margin: 0;
  font-size: 1rem;
}

.note-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  position: relative;
  margin-top: 10px;
  padding-left: 18px;
}

.note-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.validation-message {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(245, 221, 207, 0.1);
  color: #f5ddcf;
  border: 1px solid rgba(245, 221, 207, 0.22);
}

.results-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 24px;
}

.diagram-panel {
  min-height: 360px;
}

.stages-panel {
  grid-column: 1 / -1;
}

.stage-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 18px;
}

.stage-tab,
.stage-active {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.82);
}

.stage-tab {
  display: grid;
  gap: 8px;
  min-width: 180px;
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
}

.stage-tab strong,
.stage-tab-index,
.stage-active-header h4 {
  margin: 0;
}

.stage-tab-index {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-tab strong,
.stage-active-header h4 {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stage-tab.active {
  border-color: rgba(184, 93, 45, 0.34);
  box-shadow: inset 0 0 0 1px rgba(184, 93, 45, 0.18);
  background: linear-gradient(180deg, rgba(184, 93, 45, 0.12), rgba(255, 253, 248, 0.98));
}

.stage-active {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 18px;
}

.stage-active-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.diagram-frame {
  min-height: 260px;
  margin-top: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(31, 34, 29, 0.1);
  background: linear-gradient(180deg, rgba(216, 231, 223, 0.34), rgba(255, 255, 255, 0.86));
  overflow: hidden;
}

.diagram-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

.beam-panel {
  grid-column: 1 / -1;
}

.structure-panel {
  grid-column: 1 / -1;
}

.structure-frame {
  position: relative;
  min-height: 420px;
  margin-top: 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(31, 34, 29, 0.1);
  background:
    radial-gradient(circle at top left, rgba(184, 93, 45, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(250, 248, 242, 0.98), rgba(237, 243, 239, 0.95));
  overflow: hidden;
}

.structure-canvas {
  display: block;
  width: 100%;
  height: 420px;
  touch-action: none;
  user-select: none;
}

.structure-meta {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.structure-pill,
.structure-hint {
  max-width: min(100%, 620px);
  padding: 11px 14px;
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

.structure-pill {
  border: 1px solid rgba(184, 93, 45, 0.18);
  background: rgba(255, 251, 245, 0.82);
  box-shadow: 0 12px 24px rgba(57, 39, 18, 0.08);
}

.structure-pill strong,
.structure-pill span,
.structure-hint {
  display: block;
  margin: 0;
}

.structure-pill strong {
  font-size: 0.78rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.structure-pill span,
.structure-hint {
  margin-top: 4px;
}

.structure-hint {
  color: var(--muted);
  border: 1px solid rgba(31, 34, 29, 0.08);
  background: rgba(255, 255, 255, 0.68);
}

.plan-beam {
  cursor: pointer;
}

.plan-beam.active {
  filter: drop-shadow(0 0 8px rgba(31, 34, 29, 0.28));
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 18px;
  font-size: 0.94rem;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.beam-explorer,
.beam-inspector-grid,
.beam-picker-list,
.beam-meta {
  display: grid;
  gap: 16px;
}

.beam-explorer {
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  margin-top: 18px;
}

.beam-picker {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.72);
}

.beam-picker-note,
.beam-note-line {
  margin: 0;
  color: var(--muted);
}

.beam-picker-list {
  grid-template-columns: 1fr;
  max-height: 640px;
  overflow: auto;
  margin-top: 14px;
  padding-right: 6px;
}

.beam-chip {
  display: grid;
  justify-items: start;
  gap: 3px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(31, 34, 29, 0.12);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.94), rgba(246, 241, 232, 0.9));
  cursor: pointer;
  text-align: left;
}

.beam-chip strong,
.beam-chip span,
.beam-chip small,
.beam-inspector-header h4,
.beam-card h5 {
  margin: 0;
}

.beam-chip strong {
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.beam-chip span,
.beam-chip small {
  color: var(--muted);
}

.beam-chip.active {
  border-color: rgba(184, 93, 45, 0.45);
  box-shadow: inset 0 0 0 1px rgba(184, 93, 45, 0.22);
  background: linear-gradient(90deg, rgba(184, 93, 45, 0.14), rgba(255, 251, 245, 0.96));
}

.beam-chip-common {
  border-left: 6px solid rgba(184, 93, 45, 0.7);
}

.beam-chip-hip {
  border-left: 6px solid rgba(142, 67, 25, 0.78);
}

.beam-chip-jack,
.beam-chip-ridge {
  border-left: 6px solid rgba(45, 93, 80, 0.76);
}

.beam-chip-support {
  border-left: 6px solid rgba(71, 90, 52, 0.82);
}

.beam-chip-plate,
.beam-chip-shed {
  border-left: 6px solid rgba(77, 89, 81, 0.62);
}

.beam-inspector {
  display: grid;
  gap: 16px;
}

.beam-angle-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.beam-angle-chip {
  display: inline-grid;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(45, 93, 80, 0.08);
  border: 1px solid rgba(45, 93, 80, 0.14);
}

.beam-angle-chip strong,
.beam-angle-chip em {
  margin: 0;
  font-style: normal;
}

.beam-angle-chip strong {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.beam-angle-chip em {
  font-weight: 800;
}

.beam-inspector-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.72);
}

.beam-overline {
  margin: 0 0 6px;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 800;
}

.beam-inspector-header h4 {
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.beam-meta {
  justify-items: end;
}

.beam-meta span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(45, 93, 80, 0.1);
  font-size: 0.9rem;
}

.beam-inspector-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.beam-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.72);
}

.beam-card h5 {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.beam-svg-frame {
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(31, 34, 29, 0.1);
  background: #faf8f2;
}

.beam-svg-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

.beam-step-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.beam-step-list li {
  position: relative;
  margin-top: 10px;
  padding-left: 18px;
}

.beam-step-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.beam-note-line {
  margin-top: 14px;
}

.saved-panel {
  margin-top: 24px;
}

.saved-jobs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.job-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(31, 34, 29, 0.1);
  background: rgba(255, 252, 247, 0.92);
}

.job-card h4,
.job-card p {
  margin: 0;
}

.job-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.job-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 1120px) {
  .workspace-grid,
  .results-grid,
  .beam-explorer,
  .beam-inspector-grid {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1360px);
  }

  .app-header,
  .section-row,
  .field-grid,
  .field-grid-two,
  .field-grid-three,
  .form-actions,
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .app-header {
    justify-items: start;
  }

  .header-tools,
  .header-note {
    justify-items: start;
    text-align: left;
  }

  .stage-switcher {
    display: grid;
    grid-template-columns: 1fr;
  }

  .stage-active-header {
    flex-direction: column;
    align-items: start;
  }

  .structure-frame,
  .structure-canvas {
    min-height: 340px;
    height: 340px;
  }

  .structure-meta {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }
}

@media print {
  body {
    background: #fff;
  }

  body::before,
  .lang-switch,
  .form-actions,
  .saved-panel,
  .structure-meta {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .panel {
    background: #fff;
    box-shadow: none;
    border-color: #d9d9d9;
  }

  .workspace-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    color: var(--ink);
  }

  .summary-panel .panel-header p,
  .summary-panel .note-list,
  .summary-card span {
    color: var(--muted);
  }

  .summary-card {
    background: #f5f5f5;
  }

  .validation-message {
    color: var(--danger);
    border-color: #e1b8a5;
    background: var(--danger-soft);
  }
}
