:root {
  --ink: #17161b;
  --muted: #696271;
  --line: #ebe5dc;
  --cream: #fff1c6;
  --soft: #f7f5f0;
  --green: #9bcf82;
  --red: #e72e38;
  --red-dark: #ca1f29;
  --orange: #ff8a2a;
  --blue: #1d9fe6;
  --white: #ffffff;
  --shadow: 0 20px 60px rgba(35, 31, 45, .12);
  --soft-shadow: 0 14px 36px rgba(35, 31, 45, .08);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  background: var(--cream);
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--cream) 0, #fff7dc 36%, var(--soft) 36%, var(--soft) 100%);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
}

body,
button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  display: grid;
  gap: clamp(22px, 4vw, 38px);
  min-height: 100vh;
  padding:
    max(18px, env(safe-area-inset-top))
    max(16px, min(5vw, 56px))
    max(18px, env(safe-area-inset-bottom));
}

.site-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 12px 0 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.logo {
  display: block;
  width: clamp(150px, 22vw, 220px);
  max-height: 78px;
  object-fit: contain;
}

.site-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid rgba(23, 22, 27, .09);
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  color: #3d3841;
  box-shadow: 0 12px 28px rgba(35, 31, 45, .08);
  font-weight: 850;
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .72fr);
  gap: clamp(18px, 3vw, 30px);
  align-items: start;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.calculator-panel,
.guide-panel {
  width: 100%;
  min-width: 0;
}

.calculator-panel {
  display: grid;
  align-content: start;
  gap: clamp(18px, 3vw, 26px);
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid rgba(23, 22, 27, .08);
  border-radius: 28px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.eyebrow,
.guide-label,
.result-label {
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1.2;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

h1 {
  max-width: 720px;
  font-size: clamp(38px, 6vw, 74px);
  font-weight: 950;
  line-height: .98;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.lead {
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  overflow-wrap: anywhere;
}

.calc-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 4px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field span {
  color: #3d3841;
  font-size: 14px;
  font-weight: 850;
}

.field input {
  width: 100%;
  min-height: 62px;
  border: 1px solid #ddd6cb;
  border-radius: 18px;
  background: #fffdf7;
  color: var(--ink);
  padding: 12px 16px;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  line-height: 1.1;
}

.field input::placeholder {
  color: rgba(105, 98, 113, .62);
}

.field input:focus {
  border-color: rgba(231, 46, 56, .58);
  box-shadow: 0 0 0 4px rgba(231, 46, 56, .13);
  outline: none;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  box-shadow: 0 16px 34px rgba(231, 46, 56, .23);
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.primary-button:hover {
  background: var(--red-dark);
}

.primary-button:focus-visible,
.site-link:focus-visible,
.install-button:focus-visible,
.update-bar button:focus-visible {
  outline: 3px solid rgba(29, 159, 230, .45);
  outline-offset: 3px;
}

.result {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(155, 207, 130, .48);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(155, 207, 130, .20), rgba(255, 255, 255, .96));
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-grid article {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid rgba(23, 22, 27, .08);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.result-grid span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.result-grid strong {
  color: #24331e;
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 950;
  line-height: 1;
}

.error {
  padding: 12px 14px;
  border: 1px solid rgba(231, 46, 56, .2);
  border-radius: 16px;
  background: #fff0ee;
  color: var(--red-dark);
  font-weight: 850;
}

.guide-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.instruction,
.material-note,
.install-note,
.app-footer {
  border: 1px solid rgba(23, 22, 27, .08);
  border-radius: 24px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--soft-shadow);
}

.instruction,
.install-note {
  display: grid;
  gap: 16px;
  padding: clamp(20px, 4vw, 28px);
}

h2 {
  margin-top: 6px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 950;
  line-height: 1.08;
  text-wrap: balance;
}

.instruction ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: steps;
}

.instruction li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  color: #3d3841;
  font-weight: 800;
  overflow-wrap: break-word;
}

.instruction li::before {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  content: counter(steps);
  counter-increment: steps;
  font-size: 14px;
  font-weight: 950;
}

.material-note {
  margin: 0;
  padding: 16px 18px;
  background: #fff8df;
  color: #6c4719;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.install-note {
  background: #f5fbff;
}

.install-note p:not(.guide-label) {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.install-actions {
  display: grid;
  gap: 10px;
}

.install-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  box-shadow: 0 14px 30px rgba(231, 46, 56, .20);
  font-weight: 950;
  line-height: 1;
}

.install-button:hover {
  background: var(--red-dark);
}

.install-button:disabled {
  cursor: default;
  background: #d8d2ca;
  color: #524c57;
  box-shadow: none;
}

.install-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.update-bar {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto;
  padding: 12px;
  border: 1px solid rgba(23, 22, 27, .08);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 850;
  text-align: center;
}

.update-bar button {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  padding: 8px 14px;
  font-weight: 950;
}

[hidden] {
  display: none !important;
}

@media (display-mode: standalone) {
  .site-strip {
    display: none;
  }
}

body.is-standalone .site-strip {
  display: none;
}

body.is-standalone .app-shell {
  padding-top: max(14px, env(safe-area-inset-top));
}

body.is-standalone .workbench {
  align-self: stretch;
}

@media (max-width: 860px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .calc-form {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    background: var(--soft);
  }

  .app-shell {
    gap: 14px;
    width: 100%;
    max-width: 100%;
    padding: 0;
    overflow-x: hidden;
  }

  .site-strip {
    padding: max(12px, env(safe-area-inset-top)) 14px 0;
  }

  .brand-link {
    display: none;
  }

  .site-link {
    width: 100%;
  }

  .workbench {
    width: 100%;
    max-width: 100%;
    gap: 0;
    overflow-x: hidden;
  }

  .calculator-panel,
  .instruction,
  .material-note,
  .install-note,
  .app-footer {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
  }

  .calculator-panel {
    padding: 22px 14px 18px;
  }

  .calculator-panel > *,
  .instruction > *,
  .install-note > *,
  .material-note,
  .app-footer {
    width: calc(100% - 28px);
    max-width: 360px;
    margin-right: auto;
    margin-left: 14px;
  }

  .calc-form,
  .result {
    width: calc(100% - 28px);
    max-width: 360px;
  }

  .field,
  .field input,
  .primary-button,
  .install-button {
    max-width: 100%;
  }

  .install-button {
    width: 100%;
  }

  .guide-panel {
    gap: 0;
  }

  h1 {
    font-size: 33px;
  }

  .lead {
    font-size: 16px;
    max-width: 100%;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .app-footer {
    flex-direction: column;
  }

  .update-bar {
    align-items: stretch;
    flex-direction: column;
    border-radius: 16px;
  }
}
