:root {
  --primary-gradient: var(--accent);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  --warning-gradient: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(255, 255, 255, 0.2);
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 20px 40px rgba(0, 0, 0, 0.15);
  --border-radius: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Page Container */
.calculator-page {
  background: var(--bg);
  min-height: 100%;
  padding-top: 4rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 2rem);
  padding-left: 2rem;
  padding-right: 2rem;
}

/* Main Container */
.container {
  max-width: 600px;
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: var(--shadow-medium);
  border: 1px solid var(--glass-border);
  margin: 2rem auto;
  opacity: 0;
  transform: translateY(30px) scale(0.98);
  animation: containerSlideUp 0.6s ease-out 0.4s forwards;
}

@keyframes containerSlideUp {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Header */
h2 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 28px;
  font-weight: 600;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
  transform: translateY(20px);
  animation: titleFade 0.5s ease-out 0.6s forwards;
}

@keyframes titleFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-20px);
  animation: formGroupSlide 0.4s ease-out forwards;
}

.form-group:nth-child(2) {
  animation-delay: 0.8s;
}
.form-group:nth-child(3) {
  animation-delay: 0.9s;
}
.form-group:nth-child(5) {
  animation-delay: 1.3s;
}

@keyframes formGroupSlide {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.form-group::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(102, 126, 234, 0.4),
    transparent
  );
  transition: left 0.5s ease;
}

.form-group:focus-within::before {
  left: 100%;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-weight: 500;
  font-size: 14px;
}

.optional-label {
  color: #7f8c8d;
  font-style: italic;
}

input,
select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 12px;
  font-size: 16px;
  transition: var(--transition);
  background: #fff;
  color: #333;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

input:hover,
select:hover {
  border-color: var(--accent);
}

select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
}

/* Measurements Group */
.measurements-group {
  background: rgba(102, 126, 234, 0.05);
  padding: 20px;
  border-radius: 15px;
  margin-bottom: 20px;
  border: 1px solid rgba(102, 126, 234, 0.1);
  opacity: 0;
  transform: translateX(-20px);
  animation: formGroupSlide 0.4s ease-out 1s forwards;
}

.measurements-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 15px;
  font-size: 16px;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  animation: measurementTitleFade 0.4s ease-out 1.1s forwards;
}

@keyframes measurementTitleFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.measurements-title::before {
  content: "📏";
  margin-right: 8px;
  font-size: 18px;
}

.measurements-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.measurements-grid .form-group {
  opacity: 0;
  transform: translateX(-20px);
  animation: formGroupSlide 0.4s ease-out forwards;
}

.measurements-grid .form-group:nth-child(1) {
  animation-delay: 1.2s;
}
.measurements-grid .form-group:nth-child(2) {
  animation-delay: 1.3s;
}

/* Button */
.calculate-btn {
  width: 100%;
  padding: 15px;
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0;
  transform: translateY(20px);
  animation: buttonSlide 0.5s ease-out 1.5s forwards;
}

@keyframes buttonSlide {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.calculate-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.calculate-btn:active {
  transform: translateY(-1px);
}

/* Results */
.result {
  margin-top: 25px;
  padding: 20px;
  background: var(--success-gradient);
  border-radius: 15px;
  color: white;
  font-weight: 500;
  line-height: 1.6;
  box-shadow: 0 10px 20px rgba(17, 153, 142, 0.3);
  display: none;
  animation: resultSlideIn 0.6s ease-out;
}

.result.show {
  display: block;
}

@keyframes resultSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.result p {
  margin-bottom: 12px;
  font-size: 15px;
}

.result p:last-child {
  margin-bottom: 0;
}

.result strong {
  font-weight: 700;
  font-size: 17px;
}

.result-main {
  background: rgba(255, 255, 255, 0.15);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 15px;
  text-align: center;
}

.result-secondary {
  background: rgba(255, 255, 255, 0.1);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* Warning and Info */
.warning {
  background: rgba(255, 193, 7, 0.2);
  border-left: 4px solid #ffc107;
  padding: 12px 16px;
  margin: 15px 0;
  border-radius: 8px;
  color: #856404;
  font-size: 14px;
}

.info {
  background: rgba(23, 162, 184, 0.2);
  border-left: 4px solid #17a2b8;
  padding: 12px 16px;
  margin: 15px 0;
  border-radius: 8px;
  color: #0c5460;
  font-size: 14px;
}

/* Validation styles */
input:invalid {
  border-color: #e74c3c;
}

input:valid {
  border-color: #27ae60;
}

.field-valid {
  border-color: #27ae60 !important;
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1) !important;
}

.field-invalid {
  border-color: #e74c3c !important;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1) !important;
}

/* Mobile Adaptations */
@media (max-width: 768px) {
  .calculator-page {
    padding: 1rem;
    padding-top: 5rem;
  }

  .container {
    padding: 25px 20px;
    border-radius: 15px;
    max-width: 100%;
    margin: 0;
  }

  h2 {
    font-size: 24px;
    margin-bottom: 25px;
  }

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

  input,
  select {
    padding: 14px 16px;
    font-size: 16px;
  }

  .calculate-btn {
    padding: 16px;
    font-size: 16px;
  }

  .measurements-group {
    padding: 15px;
  }

  .result p {
    font-size: 14px;
  }

  .result strong {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .calculator-page {
    padding: 0.5rem;
    padding-top: 4.5rem;
  }

  .container {
    padding: 20px 15px;
  }

  h2 {
    font-size: 20px;
  }

  .measurements-group {
    padding: 15px;
  }
}

/* Enhanced for larger screens */
@media (min-width: 768px) {
  .measurements-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .calculator-page {
    padding-top: 1rem;
  }

  .container {
    padding: 15px;
    margin: 0.5rem auto;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .measurements-group {
    padding: 12px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .container,
  h2,
  .form-group,
  .measurements-group,
  .measurements-title,
  .calculate-btn {
    opacity: 1;
    transform: none;
    animation: none;
  }
}


/* Override для app layout */
.app-page .app-main {
  padding-left: 0 !important;
  padding-right: 0 !important;
  max-width: 100% !important;
}
/* Override: app layout — stretch calculator full width & height */
.app-page .app-main {
  padding: 0 !important;
  max-width: 100% !important;
  min-height: 0 !important;
}
.app-page .calculator-page {
  min-height: calc(100vh - 58px);
  padding-top: 3rem;
  padding-bottom: 4rem;
}
/* ── Guide notice (shared with body-fat calculators) ── */
.measurement-guide-section {
  margin-top: 1.5rem;
  opacity: 0;
  transform: translateY(15px);
  animation: guideNoticeSlide 0.5s ease-out 0.9s forwards;
}

@keyframes guideNoticeSlide {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.guide-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #10b981;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.guide-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.guide-text {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.guide-text h4 {
  color: #065f46;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}

.guide-button {
  background: linear-gradient(45deg, #10b981, #059669);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.guide-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  color: white;
}
/* Subtitle description block */
.subtitle {
  text-align: center;
  font-size: 14px;
  color: #f0f0f0;
  font-weight: 400;
  margin-bottom: 24px;
  line-height: 1.6;
  padding: 14px 20px;
  background: var(--accent-light, rgba(232,134,26,.08));
  border: 1px solid rgba(232,134,26,.2);
  border-radius: 12px;
}