/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  background: #f0f2f5;
  min-height: 100vh;
  color: #2d3a4a;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Container ── */
.container {
  max-width: 1140px;
  margin: 40px auto 60px auto;
  background: #ffffff;
  padding: 40px 40px 32px 40px;
  border-radius: 16px;
  border: 1px solid #e4e8ee;
  box-shadow: 0 2px 16px rgba(45, 58, 74, 0.08);
}

/* ── Headings ── */
h1 {
  text-align: center;
  font-size: 1.9rem;
  font-weight: 700;
  color: #1a2332;
  margin: 0 0 8px 0;
  letter-spacing: 0.5px;
}

h1::after {
  content: '';
  display: block;
  width: 52px;
  height: 3px;
  background: #4e9e5d;
  border-radius: 2px;
  margin: 10px auto 28px auto;
}

h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #1a2332;
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid #e8ecf1;
}

/* ── Row & Columns ── */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

.col {
  flex: 1 1 0;
  min-width: 240px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 20px 18px 16px 18px;
  border: 1px solid #e4e8ee;
}

/* ── Labels ── */
label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4a5568;
  display: block;
  margin-bottom: 4px;
  letter-spacing: 0.1px;
}

/* ── Inputs & Selects ── */
input[type="number"],
select {
  width: 100%;
  padding: 8px 11px;
  margin: 2px 0 14px 0;
  border: 1.5px solid #dde2ea;
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.9rem;
  color: #2d3a4a;
  transition: border-color 0.18s, box-shadow 0.18s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234a5568' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}

input[type="number"]:focus,
select:focus {
  border-color: #4e9e5d;
  box-shadow: 0 0 0 3px rgba(78, 158, 93, 0.12);
  outline: none;
  background: #ffffff;
}

input[type="number"]:hover,
select:hover {
  border-color: #b0b8c4;
}

/* ── Radio Buttons ── */
input[type="radio"] {
  accent-color: #4e9e5d;
  margin-right: 5px;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Buttons ── */
button {
  background: #2d3a4a;
  color: #ffffff;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
  box-shadow: 0 1px 4px rgba(45, 58, 74, 0.15);
}

button:hover {
  background: #1a2332;
  box-shadow: 0 3px 10px rgba(45, 58, 74, 0.2);
}

button:active {
  transform: scale(0.98);
}

/* Calculate button — primary accent */
button[onclick*="calculate"] {
  background: #4e9e5d;
  padding: 11px 32px;
  font-size: 0.95rem;
  display: block;
  margin: 18px auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(78, 158, 93, 0.25);
}

button[onclick*="calculate"]:hover {
  background: #3d8a4b;
  box-shadow: 0 4px 14px rgba(78, 158, 93, 0.3);
}

/* Add Span button */
#addSpanBtn {
  background: transparent;
  color: #4e9e5d;
  border: 1.5px solid #4e9e5d;
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  margin: 8px 0 18px 0;
  box-shadow: none;
}

#addSpanBtn:hover {
  background: #f0faf2;
  box-shadow: none;
}

/* Add Load button */
.addLoadBtn {
  background: transparent;
  color: #4a5568;
  border: 1.5px solid #dde2ea;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 6px;
  box-shadow: none;
}

.addLoadBtn:hover {
  background: #f8fafc;
  border-color: #b0b8c4;
  box-shadow: none;
}

/* Remove buttons */
.removeBtn,
.removeLoadBtn {
  background: transparent;
  color: #c0392b;
  border: 1.5px solid #e8c0bc;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 10px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  box-shadow: none;
}

.removeBtn:hover,
.removeLoadBtn:hover {
  background: #fff0ef;
  border-color: #c0392b;
  box-shadow: none;
}

/* Download button */
#downloadBtn {
  background: #2d3a4a !important;
  color: #fff !important;
  border: none !important;
  padding: 9px 20px !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
  position: absolute !important;
  top: 18px !important;
  right: 18px !important;
  z-index: 10 !important;
  display: block !important;
  box-shadow: 0 1px 4px rgba(45, 58, 74, 0.15) !important;
  transition: background 0.18s !important;
}

#downloadBtn:hover {
  background: #1a2332 !important;
}

/* ── Details / Summary (Span sections) ── */
details {
  margin-bottom: 16px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e4e8ee;
  padding: 14px 18px 12px 18px;
  transition: box-shadow 0.18s;
}

details[open] {
  box-shadow: 0 2px 8px rgba(45, 58, 74, 0.07);
}

summary {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2d3a4a;
  cursor: pointer;
  outline: none;
  margin-bottom: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

summary::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 2px solid #4e9e5d;
  border-bottom: 2px solid #4e9e5d;
  transform: rotate(-45deg);
  transition: transform 0.2s;
  margin-right: 2px;
  flex-shrink: 0;
}

details[open] summary::before {
  transform: rotate(45deg);
  margin-top: -4px;
}

/* ── Result Area ── */
#resultArea {
  position: relative;
  min-height: 60px;
  margin-top: 28px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e4e8ee;
  padding: 24px 24px 16px 24px;
}

#resultsContent {
  font-size: 0.95rem;
  color: #2d3a4a;
  line-height: 1.7;
}

#steelCheckArea {
  margin-top: 16px;
  font-size: 0.93rem;
  color: #2d3a4a;
}

.result {
  background: #eef6f0;
  border: 1px solid #c3e0c9;
  border-left: 4px solid #4e9e5d;
  padding: 14px 16px;
  border-radius: 8px;
  margin-top: 18px;
  border-radius: 0 8px 8px 0;
}

/* ── Stiffness info blocks ── */
.col strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #6b7a8d;
}

/* ── Canvas ── */
canvas {
  display: block;
  margin: 20px auto 12px auto;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #e4e8ee;
}

/* ── Steel Bar Reference Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e4e8ee;
  font-size: 0.875rem;
}

th {
  background: #2d3a4a;
  color: #ffffff;
  font-weight: 600;
  padding: 10px 8px;
  text-align: center;
  letter-spacing: 0.3px;
}

td {
  border: 1px solid #edf0f4;
  padding: 8px 6px;
  text-align: center;
  color: #3a4656;
}

tr:nth-child(even) td {
  background: #f5f8fb;
}

tr:hover td {
  background: #eef6f0;
}

/* ── Placeholder ── */
::-webkit-input-placeholder { color: #b8bec7; }
::-moz-placeholder          { color: #b8bec7; }
:-ms-input-placeholder      { color: #b8bec7; }
::placeholder               { color: #b8bec7; }

/* ── Scrollbar (subtle) ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b0b8c4; }

/* ══════════════════════════════════════════════
   RESPONSIVE — Tablet (≤900px)
══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .container {
    margin: 0;
    padding: 24px 20px 24px 20px;
    border-radius: 0;
    box-shadow: none;
    border: none;
    border-top: none;
  }

  h1 { font-size: 1.6rem; }

  .row {
    flex-direction: column;
    gap: 12px;
  }

  .col {
    min-width: 100%;
    padding: 16px 14px 12px 14px;
  }

  input[type="number"],
  select {
    width: 100%;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
  }

  #resultArea {
    padding: 16px 14px 12px 14px;
  }

  #downloadBtn {
    position: static !important;
    display: block !important;
    margin: 12px 0 0 0 !important;
    width: 100% !important;
    text-align: center !important;
  }

  details {
    padding: 12px 14px 10px 14px;
  }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — Mobile (≤600px)
══════════════════════════════════════════════ */
@media (max-width: 600px) {
  /* Root font size slightly smaller so everything scales down */
  html { font-size: 14px; }

  body {
    background: #ffffff;
    font-size: 14px;
  }

  /* Container fills the full screen, no rounding or gaps */
  .container {
    margin: 0;
    padding: 16px 14px 24px 14px;
    border-radius: 0;
    box-shadow: none;
    border: none;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Tighter heading */
  h1 {
    font-size: 1.3rem;
    letter-spacing: 0.2px;
  }

  h1::after {
    margin-bottom: 16px;
  }

  h2 {
    font-size: 0.72rem;
    margin-bottom: 10px;
  }

  /* Columns always stack */
  .row {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

  .col {
    min-width: 100%;
    width: 100%;
    padding: 12px 12px 10px 12px;
    border-radius: 10px;
  }

  /* Inputs — full width, touch-friendly height */
  input[type="number"],
  select {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;       /* prevents iOS zoom on focus */
    margin-bottom: 10px;
    border-radius: 8px;
  }

  label {
    font-size: 0.8rem;
    margin-bottom: 2px;
  }

  /* Radio group wraps and has bigger tap targets */
  input[type="radio"] {
    width: 17px;
    height: 17px;
  }

  /* Buttons — full width on mobile for easy tapping */
  button {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    text-align: center;
    border-radius: 8px;
    margin-top: 6px;
  }

  button[onclick*="calculate"] {
    padding: 13px 16px;
    font-size: 1rem;
    width: 100%;
  }

  #addSpanBtn {
    width: 100%;
    margin-bottom: 10px;
  }

  .addLoadBtn {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .removeBtn,
  .removeLoadBtn {
    width: 100%;
    margin-left: 0;
    margin-top: 6px;
    padding: 9px 14px;
    text-align: center;
  }

  #downloadBtn {
    position: static !important;
    width: 100% !important;
    margin: 10px 0 0 0 !important;
    padding: 12px 16px !important;
    text-align: center !important;
    font-size: 0.95rem !important;
    border-radius: 8px !important;
  }

  /* Details/summary — span sections */
  details {
    padding: 10px 12px 8px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
  }

  summary {
    font-size: 0.88rem;
  }

  /* Span input rows stack vertically */
  details > div {
    flex-direction: column !important;
    gap: 0 !important;
  }

  /* Canvas — constrained to screen */
  canvas {
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    min-width: 0 !important;
    border-radius: 8px;
  }

  /* Result area */
  #resultArea {
    padding: 14px 12px 12px 12px;
    border-radius: 10px;
    margin-top: 16px;
  }

  #resultsContent,
  #steelCheckArea {
    font-size: 0.88rem;
    overflow-x: auto;
    max-width: 100vw;
  }

  .result {
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  /* Table — horizontal scroll on mobile */
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.78rem;
    border-radius: 8px;
  }

  th, td {
    padding: 7px 5px;
    white-space: nowrap;
  }

  /* Stiffness blocks stack */
  .stiff-block,
  div[style*="display: flex"][style*="gap: 20px"] {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* Load position inputs stack */
  div[style*="display: flex"][style*="flex-wrap: wrap"] {
    flex-direction: column !important;
    gap: 0 !important;
  }

  /* Full-width labels with inputs inside them */
  label[style*="width: 320px"] {
    width: 100% !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  label[style*="width: 320px"] input {
    width: 100% !important;
  }

  /* Radio group wraps neatly */
  #loadTypeRadios {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
}