:root {
  color-scheme: dark;
  --page: #071225;
  --page-deep: #040b18;
  --card: #f7f9fc;
  --card-soft: #eef3f9;
  --ink: #101c2f;
  --muted: #657188;
  --line: #dce4ee;
  --white: #ffffff;
  --blue: #2f7df6;
  --blue-dark: #145bc6;
  --cyan: #62d6ff;
  --orange: #ff8a3d;
  --danger: #c1374e;
  --radius: 28px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--page-deep); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--white);
  background:
    radial-gradient(circle at 14% 10%, rgba(47, 125, 246, .2), transparent 30rem),
    radial-gradient(circle at 88% 60%, rgba(98, 214, 255, .09), transparent 32rem),
    linear-gradient(145deg, var(--page) 0%, var(--page-deep) 100%);
}

button, input, select { font: inherit; }

.page-shell {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  width: min(900px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 48px;
}

.page-shell::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  opacity: .18;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.visual-card {
  display: grid;
  place-items: center;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 64% 22%, rgba(255, 138, 61, .12), transparent 34%),
    linear-gradient(155deg, rgba(20, 50, 91, .56), rgba(4, 13, 29, .46));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 26px 60px rgba(0,0,0,.24);
}

.press-diagram {
  position: relative;
  width: min(500px, 92%);
  aspect-ratio: 2 / 3;
}

.press-diagram img,
.diagram-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.press-diagram img {
  object-fit: contain;
  filter: drop-shadow(0 24px 28px rgba(0,0,0,.34));
}

.diagram-overlay { z-index: 2; overflow: visible; }

.measure {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.85));
}

.measure-cyan { stroke: var(--cyan); }
.measure-orange { stroke: var(--orange); }

.diagram-label {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 48px;
  font-weight: 850;
  paint-order: stroke fill;
  stroke: #071225;
  stroke-width: 12px;
  stroke-linejoin: round;
}

.label-cyan { fill: var(--cyan); }
.label-orange { fill: var(--orange); }

.calculator-card {
  width: min(800px, 100%);
  color: var(--ink);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 38px 100px rgba(0,0,0,.4), inset 0 1px 0 #fff;
}

.card-header { padding: 30px 32px 22px; }

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  font-weight: 760;
  letter-spacing: -.045em;
  line-height: 1.08;
  text-wrap: balance;
}

#calculator {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 32px;
}

.field {
  position: relative;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.field:focus-within {
  z-index: 1;
  border-color: #85b3fa;
  box-shadow: 0 0 0 4px rgba(47,125,246,.11);
  transform: translateY(-1px);
}

.field.is-invalid { border-color: #efadba; }

.result-field {
  border-color: #b9d3fc;
  background: linear-gradient(145deg, #ffffff 0%, #edf5ff 100%);
}

.field-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  margin-bottom: 9px;
}

.field-heading label {
  color: #3c4a5f;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.25;
}

.field-heading label span {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 28px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--blue-dark);
  background: #e9f2ff;
  font-size: .95rem;
  font-weight: 800;
  font-style: italic;
}

.clear-field {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0 0 2px;
  border: 0;
  border-radius: 8px;
  color: #9aa5b4;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: color .15s ease, background .15s ease;
}

.clear-field:hover,
.clear-field:focus-visible { color: var(--ink); background: var(--card-soft); outline: none; }

.control-row { display: flex; min-width: 0; }

.control-row input,
.control-row select {
  min-width: 0;
  height: 46px;
  border: 0;
  color: var(--ink);
  background: transparent;
  outline: none;
}

.control-row input {
  width: 100%;
  padding: 0 8px 0 0;
  font-size: 1.5rem;
  font-weight: 690;
  letter-spacing: -.025em;
}

.control-row input[readonly] { color: var(--blue-dark); }
.control-row input::placeholder { color: #c4ccd7; }

.control-row select,
.control-row .fixed-unit {
  flex: 0 0 auto;
  max-width: 112px;
  padding: 0 27px 0 11px;
  border-left: 1px solid var(--line);
  color: #536177;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 650;
}

.control-row .fixed-unit {
  display: grid;
  place-items: center;
  min-width: 52px;
  padding-right: 11px;
}

.control-row .result-unit {
  min-width: 88px;
  font-size: .82rem;
}

.field-error {
  display: none;
  margin-top: 7px;
  color: var(--danger);
  font-size: .72rem;
}

.is-invalid .field-error { display: block; }

.form-footer {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 2px 0 22px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#calculate {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 15px;
  border: 1px solid var(--blue);
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, #3988ff, #1967dc);
  box-shadow: 0 8px 20px rgba(47,125,246,.24);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 750;
  transition: border-color .15s ease, transform .15s ease;
}

#calculate:hover { border-color: var(--blue-dark); transform: translateY(-1px); }
#calculate:focus-visible { outline: 3px solid rgba(47,125,246,.25); outline-offset: 2px; }

#calculate svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.formula-note {
  padding: 18px 32px 21px;
  border-top: 1px solid #d9e2ed;
  text-align: center;
  background: #eaf0f7;
}

.formula-note strong {
  color: #284f86;
  font-size: .98rem;
  letter-spacing: .01em;
}

.formula-note p {
  max-width: 680px;
  margin: 8px auto 0;
  color: #6a778b;
  font-size: .78rem;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 28px, 620px);
    min-height: auto;
    gap: 18px;
    padding: 18px 0 34px;
  }

  .press-diagram { width: min(460px, 96%); }
  .calculator-card, .visual-card { border-radius: 22px; }
  .card-header { padding: 24px 22px 18px; }
  h1 { font-size: clamp(1.75rem, 8vw, 2.2rem); }
  #calculator { grid-template-columns: 1fr; padding: 0 22px; }
  .form-footer { grid-column: auto; }
  #calculate { min-height: 50px; }
  .formula-note { padding: 17px 22px 20px; }
}

@media (max-width: 430px) {
  .page-shell { width: min(100% - 20px, 620px); }
  .press-diagram { width: 100%; }
  .card-header { padding-inline: 18px; }
  #calculator { padding-inline: 18px; }
  .field-heading label { max-width: calc(100% - 34px); }
  .diagram-label { font-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01s !important; }
}
