* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  font-family: 'Source Code Pro', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 20px;
  background: #1a1a1a;
}

body::before {
  content: '';
  position: fixed;
  top: -5px;
  left: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  background: url('img/bg_borismek.webp') no-repeat top center;
  background-size: cover;
  z-index: -1;
}

/* ── Card: riveted steel panel ── */
.card {
  background: linear-gradient(145deg, #3a3632, #2a2622, #33302c);
  border: 2px solid #5a5347;
  border-radius: 4px;
  padding: 32px 36px;
  width: 100%;
  max-width: 460px;
  z-index: 1;
  position: relative;
  box-shadow:
    0 0 0 1px #1a1714,
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Corner rivets */
.card::before,
.card::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8a7d6b, #4a4238);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.08);
}
.card::before { top: 10px; left: 10px; }
.card::after { top: 10px; right: 10px; }
.card .rivets-bottom::before,
.card .rivets-bottom::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8a7d6b, #4a4238);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.08);
}
.card .rivets-bottom::before { bottom: 10px; left: 10px; }
.card .rivets-bottom::after { bottom: 10px; right: 10px; }

h1 {
  font-family: 'Oswald', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #c9a84c;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.subtitle {
  color: #8a8078;
  font-size: 0.75rem;
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}

/* ── Toggle ── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a4238;
  border-radius: 3px;
  padding: 10px 14px;
}

.toggle-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c9a84c;
  transition: color 0.2s;
  text-transform: uppercase;
}

#label-rpm { flex: 1; }

.toggle-label.dim { color: #5a5347; }

/* ── Milling checkbox ── */
.milling-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.milling-check input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid #6a6358;
  border-radius: 2px;
  background: rgba(0,0,0,0.3);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.milling-check input[type="checkbox"]:checked {
  background: linear-gradient(180deg, #c9a84c, #9a7a2c);
  border-color: #d4b85c;
}

.milling-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #1a1714;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.milling-check span {
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #a09888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.switch {
  position: relative;
  width: 72px;
  height: 28px;
  flex-shrink: 0;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #5a5347, #3a3632);
  border: 1px solid #6a6358;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.25s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 20px;
  background: linear-gradient(180deg, #c9a84c, #9a7a2c);
  border-radius: 2px;
  top: 3px;
  left: 3px;
  transition: transform 0.25s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

input:checked + .slider { background: linear-gradient(180deg, #5a5347, #3a3632); }
input:checked + .slider::before { transform: translateX(42px); }

/* ── Section label ── */
.section-label {
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #6a6358;
  margin-bottom: 12px;
  border-bottom: 1px solid #4a4238;
  padding-bottom: 6px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #a09888;
}

label span {
  font-weight: 400;
  color: #6a6358;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #4a4238;
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.2s;
  background: rgba(0,0,0,0.3);
}

.input-wrap:focus-within {
  border-color: #c9a84c;
  box-shadow: 0 0 0 2px rgba(201,168,76,0.15);
}

input[type="number"] {
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: 'Source Code Pro', monospace;
  font-size: 1rem;
  flex: 1;
  background: transparent;
  color: #e8dcc8;
}

input[type="number"]::placeholder {
  color: #5a5347;
}

/* Hide number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.unit {
  padding: 0 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a7d6b;
  background: rgba(0,0,0,0.2);
  border-left: 1px solid #4a4238;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Button ── */
button {
  margin-top: 24px;
  width: 100%;
  background: linear-gradient(180deg, #c9a84c, #9a7a2c);
  color: #1a1714;
  border: 1px solid #d4b85c;
  border-radius: 3px;
  padding: 12px;
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

button:hover {
  background: linear-gradient(180deg, #d4b85c, #b08a3c);
  box-shadow: 0 2px 12px rgba(201,168,76,0.3);
}
button:active { transform: scale(0.98); }

/* ── Results ── */
.results {
  margin-top: 24px;
  background: rgba(0,0,0,0.25);
  border: 1px solid #4a4238;
  border-radius: 3px;
  padding: 18px 20px;
  display: none;
}

.results.visible { display: block; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
}

.result-row + .result-row { border-top: 1px solid #3a3632; }

.result-label {
  font-size: 0.8rem;
  color: #8a8078;
  font-weight: 600;
}

.result-value {
  font-family: 'Oswald', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #c9a84c;
  text-shadow: 0 0 8px rgba(201,168,76,0.3);
}

.result-unit {
  font-size: 0.7rem;
  color: #6a6358;
  margin-left: 4px;
  text-transform: uppercase;
}

.error {
  color: #d45a5a;
  font-size: 0.8rem;
  margin-top: 10px;
  display: none;
}

/* ── Mobile ── */
@media (max-width: 500px) {
  body {
    padding: 10px;
    align-items: flex-start;
    padding-top: 15px;
  }

  .card {
    padding: 16px 18px;
    max-width: 360px;
  }

  h1 {
    font-size: 1.1rem;
  }

  .toggle-row {
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 16px;
  }

  .toggle-label {
    font-size: 0.8rem;
  }

  .milling-check span {
    font-size: 0.75rem;
  }

  .switch {
    width: 56px;
    height: 24px;
  }

  .slider::before {
    width: 18px;
    height: 16px;
    top: 3px;
    left: 3px;
  }

  input:checked + .slider::before {
    transform: translateX(30px);
  }

  .section-label {
    font-size: 0.65rem;
    margin-bottom: 8px;
  }

  .input-group {
    gap: 10px;
  }

  label {
    font-size: 0.7rem;
  }

  input[type="number"] {
    padding: 8px 10px;
    font-size: 16px;
  }

  .unit {
    padding: 0 8px;
    font-size: 0.65rem;
  }

  button {
    margin-top: 18px;
    padding: 10px;
    font-size: 0.85rem;
  }

  .results {
    margin-top: 18px;
    padding: 14px 16px;
  }

  .result-label {
    font-size: 0.7rem;
  }

  .result-value {
    font-size: 1.1rem;
  }

  .result-unit {
    font-size: 0.6rem;
  }
}
