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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  padding: 20px 16px 8px;
  flex-shrink: 0;
}

.header-center {
  justify-content: center;
  padding: 32px 16px 20px;
}

.header-back {
  gap: 4px;
  padding: 16px 16px 4px;
}

.header h1.logo {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 2px;
}

.header h2 {
  font-size: 20px;
  font-weight: 600;
}

/* ── Back button ── */
.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  color: #007aff;
  margin-left: -8px;
}

.btn-back svg {
  width: 24px;
  height: 24px;
}

.btn-back:active {
  opacity: 0.5;
}

/* ── Main content ── */
.main {
  flex: 1;
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main-with-home {
  padding-bottom: 80px;
}

/* ── Card ── */
.card {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 18px 18px;
  background: #fff;
  border: none;
  border-radius: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.15s;
  gap: 12px;
}

.card:active {
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 2px;
}

.card-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: #86868b;
}

/* ── Arrow ── */
.card-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: #c7c7cc;
}

.card-arrow svg {
  width: 20px;
  height: 20px;
}

/* ── Home card ── */
.card-home {
  padding: 26px 20px;
  min-height: 88px;
  gap: 14px;
  border-radius: 20px;
}

.card-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #f0f0f5;
  color: #007aff;
}

.card-icon svg {
  width: 24px;
  height: 24px;
}

.card-home .card-title {
  font-size: 20px;
}

.card-home .card-subtitle {
  font-size: 14px;
}

/* ── Bottom nav / home button ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 12px 16px;
  background: linear-gradient(transparent, #f5f5f7 30%);
  pointer-events: none;
  z-index: 10;
}

.bottom-nav {
  max-width: 480px;
  margin: 0 auto;
}

.btn-home {
  pointer-events: auto;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  background: #007aff;
  color: #fff;
  border: none;
  border-radius: 22px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 8px rgba(0,122,255,0.3);
}

.btn-home:active {
  background: #005bbf;
  box-shadow: none;
}

/* ── Placeholder ── */
.placeholder-text {
  text-align: center;
  font-size: 16px;
  color: #86868b;
  padding: 60px 20px;
}

/* ══════════════════════════════════════════
   Экран "Материал корпуса" — надстройки над .card
   ══════════════════════════════════════════ */

.material-card {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}

.material-card:active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.material-card .card-body {
  gap: 14px;
}

.material-card .card-title {
  color: #111827;
}

.material-header {
  text-align: center;
  padding: 2px 0 4px;
}

.material-title {
  font-size: 20px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 0 0 4px;
}

.material-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: #6B7280;
  margin: 0;
  line-height: 1.4;
}

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

.material-label {
  font-size: 14px;
  font-weight: 500;
  color: #6B7280;
}

.material-select {
  width: 100%;
  height: 48px;
  padding: 0 36px 0 14px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 400;
  color: #111827;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  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' fill='none' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
}

.material-select:focus {
  border-color: #0A84FF;
}

.material-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.material-pill {
  font-size: 13px;
  font-weight: 400;
  color: #6B7280;
  background: #F3F4F6;
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

.material-pill strong {
  font-weight: 600;
  color: #111827;
}

.material-custom-row {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.material-custom-label {
  font-size: 13px;
  font-weight: 500;
  color: #6B7280;
}

.material-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 400;
  color: #111827;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.material-input:focus {
  border-color: #0A84FF;
}

.material-input::placeholder {
  color: #aeaeb2;
  font-weight: 400;
}

.material-input[type="number"] {
  -moz-appearance: textfield;
}

.material-input[type="number"]::-webkit-outer-spin-button,
.material-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.material-result-area {
  font-size: 24px;
  font-weight: 700;
  color: #0A84FF;
  line-height: 1.2;
  margin: 4px 0;
  text-align: center;
}

.material-result-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  font-weight: 400;
  color: #6B7280;
  line-height: 1.4;
  text-align: center;
}

.material-card--result {
  background: #F0F7FF;
  border: 1px solid #E0EEFF;
}

/* ══════════════════════════════════════════
   Экран "Задняя стенка" — надстройки над .card
   ══════════════════════════════════════════ */

.backpanel-card {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}

.backpanel-card:active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.backpanel-card .card-body {
  gap: 14px;
}

.backpanel-card .card-title {
  color: #111827;
}

.backpanel-card--summary {
  background: #F0F7FF;
  border: 1px solid #E0EEFF;
}

.backpanel-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
}

.backpanel-custom-grid {
  display: none;
  flex-direction: column;
  gap: 10px;
}

/* ══════════════════════════════════════════
   Экран "Фасады" — надстройки над .card
   ══════════════════════════════════════════ */

.facade-card {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}

.facade-card:active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.facade-card .card-body {
  gap: 14px;
}

.facade-card .card-title {
  color: #111827;
}

.facade-card--summary {
  background: #F0F7FF;
  border: 1px solid #E0EEFF;
}

.facade-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
}

.facade-note {
  font-size: 13px;
  font-weight: 400;
  color: #6B7280;
  line-height: 1.4;
  padding: 8px 12px;
  background: #F9FAFB;
  border-radius: 10px;
}

/* ══════════════════════════════════════════
   Экран "Кромка" — надстройки над .card
   ══════════════════════════════════════════ */

.edge-card {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}

.edge-card:active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.edge-card .card-body {
  gap: 14px;
}

.edge-card .card-title {
  color: #111827;
}

.edge-card--summary {
  background: #F0F7FF;
  border: 1px solid #E0EEFF;
}

.edge-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edge-pill {
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

.edge-pill--yes {
  background: #ECFDF5;
  color: #065F46;
}

.edge-pill--no {
  background: #F3F4F6;
  color: #6B7280;
}

.edge-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
}

.edge-formula {
  font-size: 15px;
  font-weight: 600;
  color: #0A84FF;
  padding: 6px 0;
}

.edge-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
}

.edge-note {
  font-size: 14px;
  font-weight: 400;
  color: #92400E;
  line-height: 1.5;
  padding: 10px 14px;
  background: #FFFBEB;
  border-radius: 10px;
  border: 1px solid #FDE68A;
}

/* ══════════════════════════════════════════
   Экран "Штанги" — надстройки над .card
   ══════════════════════════════════════════ */

.rod-card {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
}

.rod-card:active {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.rod-card .card-body {
  gap: 14px;
}

.rod-card .card-title {
  color: #111827;
}

.rod-card--summary {
  background: #F0F7FF;
  border: 1px solid #E0EEFF;
}

.rod-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rod-pill {
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 20px;
  white-space: normal;
  line-height: 1.4;
}

.rod-pill--rule {
  background: #EFF6FF;
  color: #1E40AF;
  font-weight: 600;
  width: 100%;
  text-align: center;
}

.rod-pill--lt {
  background: #FEF2F2;
  color: #991B1B;
}

.rod-pill--gt {
  background: #ECFDF5;
  color: #065F46;
}

.rod-pill--eq {
  background: #FFFBEB;
  color: #92400E;
}

.rod-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
}

.rod-result {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
  padding: 12px 14px;
  background: #F9FAFB;
  border-radius: 12px;
  border: 1px solid #E5E7EB;
}

.rod-recommendation {
  font-size: 15px;
  font-weight: 600;
  padding: 4px 0;
}

.rod-rec--lt {
  color: #991B1B;
}

.rod-rec--gt {
  color: #065F46;
}

.rod-rec--eq {
  color: #92400E;
}

.rod-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 400;
  color: #111827;
  line-height: 1.5;
}
