:root {
  --bg-deep: #0c1a32;
  --bg-mid: #122848;
  --accent-cyan: #0891b2;
  --accent-blue: #2563eb;
  --accent-violet: #6366f1;
  --text-primary: #0f2d4a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-on-accent: #ffffff;
  --panel-bg: rgba(240, 247, 255, 0.92);
  --panel-bg-alt: rgba(255, 255, 255, 0.82);
  --panel-inner: rgba(255, 255, 255, 0.65);
  --glass-bg: rgba(236, 245, 255, 0.88);
  --glass-border: rgba(59, 130, 246, 0.28);
  --glass-highlight: rgba(255, 255, 255, 0.95);
  --input-bg: rgba(255, 255, 255, 0.96);
  --input-border: rgba(59, 130, 246, 0.22);
  --glow-cyan: rgba(34, 211, 238, 0.4);
  --glow-blue: rgba(59, 130, 246, 0.38);
  --panel-shadow: 0 8px 32px rgba(15, 60, 120, 0.1), 0 2px 8px rgba(59, 130, 246, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* —— 科技感背景层 —— */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-mesh {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(56, 189, 248, 0.28) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 75%, rgba(37, 99, 235, 0.22) 0%, transparent 50%),
    radial-gradient(ellipse 70% 60% at 50% 100%, rgba(34, 211, 238, 0.14) 0%, transparent 45%),
    radial-gradient(ellipse 50% 40% at 60% 30%, rgba(59, 130, 246, 0.12) 0%, transparent 50%),
    linear-gradient(165deg, #0c1a32 0%, #0f2448 35%, #123060 65%, #0e2240 100%);
}

.bg-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 0.85;
  pointer-events: none;
}

.bg-grid {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 1;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(500px) rotateX(58deg) translateY(-12%);
  transform-origin: center 30%;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, transparent 75%);
  animation: grid-drift 40s linear infinite;
}

@keyframes grid-drift {
  0% {
    transform: perspective(500px) rotateX(58deg) translateY(-12%) translateZ(0);
  }
  100% {
    transform: perspective(500px) rotateX(58deg) translateY(-12%) translateZ(48px);
  }
}

.bg-orbit {
  position: absolute;
  top: 8%;
  right: -8%;
  z-index: 3;
  width: min(420px, 70vw);
  height: min(420px, 70vw);
  border: 1px solid rgba(34, 211, 238, 0.12);
  border-radius: 50%;
  box-shadow:
    inset 0 0 60px rgba(34, 211, 238, 0.05),
    0 0 80px rgba(59, 130, 246, 0.08);
  animation: orbit-spin 80s linear infinite;
}

.bg-orbit::before,
.bg-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.08);
}

.bg-orbit::before {
  inset: 18%;
  animation: orbit-spin 50s linear infinite reverse;
}

.bg-orbit::after {
  inset: 36%;
  border-color: rgba(59, 130, 246, 0.14);
  animation: orbit-spin 35s linear infinite;
}

@keyframes orbit-spin {
  to {
    transform: rotate(360deg);
  }
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  z-index: 4;
  animation: glow-pulse 8s ease-in-out infinite;
}

.bg-glow-1 {
  width: 320px;
  height: 320px;
  top: -8%;
  left: -5%;
  background: var(--glow-blue);
  animation-delay: 0s;
}

.bg-glow-2 {
  width: 280px;
  height: 280px;
  bottom: 15%;
  right: -6%;
  background: rgba(37, 99, 235, 0.32);
  animation-delay: -3s;
}

.bg-glow-3 {
  width: 200px;
  height: 200px;
  top: 45%;
  left: 35%;
  background: var(--glow-cyan);
  animation-delay: -5s;
  opacity: 0.35;
}

@keyframes glow-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.45;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.65;
  }
}

/* —— 主内容 —— */
.container {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.page-header {
  position: relative;
  text-align: center;
  padding: 20px 24px;
  margin-bottom: 18px;
  color: var(--text-primary);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(224, 242, 254, 0.9) 50%, rgba(219, 234, 254, 0.88) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--panel-shadow),
    inset 0 1px 0 var(--glass-highlight),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  overflow: hidden;
}

.page-header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.header-globe {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  color: var(--accent-blue);
  filter: drop-shadow(0 0 10px rgba(37, 99, 235, 0.35));
  animation: globe-spin 24s linear infinite;
}

@keyframes globe-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.page-header-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

.page-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), var(--accent-cyan), transparent);
  opacity: 0.85;
}

.page-header::after {
  content: "EARTH MOTION CALCULATOR";
  display: block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.35em;
  color: var(--accent-blue);
  opacity: 0.75;
}

.main-content {
  min-height: calc(100vh - 100px);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--panel-shadow),
    inset 0 1px 0 var(--glass-highlight),
    0 0 0 1px rgba(255, 255, 255, 0.4) inset;
}

.main-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan), var(--accent-blue));
  opacity: 0.7;
  z-index: 1;
  pointer-events: none;
}

.calculator-area {
  padding: 18px;
  overflow-y: auto;
}

.calculator-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(224, 242, 254, 0.75) 100%);
  border-radius: 12px;
  border: 1px solid var(--input-border);
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.selector-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-blue);
  white-space: nowrap;
}

.selector-picker,
.picker-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text-primary);
  min-height: 44px;
  min-width: 200px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232563eb' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(15, 60, 120, 0.06);
}

.selector-picker:hover,
.selector-picker:focus,
select.field-select:hover,
select.field-select:focus,
input:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}

#calculator-type-select {
  flex: 1;
  max-width: 280px;
}

#calculator-type-select option {
  background: #f0f7ff;
  color: var(--text-primary);
}

.calculator-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95) 0%, rgba(236, 245, 255, 0.88) 100%);
  border-radius: 14px;
  padding: 22px;
  max-width: 100%;
  border: 1px solid var(--glass-border);
  box-shadow:
    var(--panel-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  position: relative;
}

.calculator-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.35), transparent);
}

.calculator-card[hidden] {
  display: none !important;
}

.input-group {
  margin-bottom: 14px;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: none;
}

.input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.input-row .input-group {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select.field-select {
  width: 100%;
  padding: 12px 12px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text-primary);
  min-height: 44px;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 3px rgba(15, 60, 120, 0.05);
}

input::placeholder {
  color: #94a3b8;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.65;
  cursor: pointer;
}

select.field-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--input-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232563eb' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

select.field-select option {
  background: #f0f7ff;
  color: var(--text-primary);
}

.calculate-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 50%, #1d4ed8 100%);
  color: var(--text-on-accent);
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 16px;
  cursor: pointer;
  letter-spacing: 0.08em;
  box-shadow:
    0 4px 16px rgba(37, 99, 235, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.calculate-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 8px 24px rgba(37, 99, 235, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}

.calculate-btn:active {
  transform: translateY(0);
  opacity: 0.92;
}

.result {
  margin-top: 16px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(224, 242, 254, 0.95) 0%, rgba(219, 234, 254, 0.9) 100%);
  border-radius: 10px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-left: 3px solid var(--accent-blue);
  font-weight: 600;
  color: var(--text-primary);
  white-space: pre-line;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.08);
}

.result[hidden] {
  display: none !important;
}

.info-text {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(241, 245, 249, 0.85);
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-left: 3px solid var(--accent-blue);
}

.info-title {
  font-size: 13px;
  font-weight: bold;
  color: var(--accent-blue);
  margin-bottom: 8px;
  margin-top: 6px;
}

.info-title:first-child {
  margin-top: 0;
}

.info-content {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.85;
  margin-bottom: 6px;
  word-break: break-word;
}

.info-content:last-child {
  margin-bottom: 0;
}

.conditional-field[hidden] {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  max-width: 80%;
  text-align: center;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--panel-shadow);
}

.toast.show {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .bg-grid,
  .bg-orbit,
  .bg-orbit::before,
  .bg-orbit::after,
  .bg-glow,
  .header-globe {
    animation: none;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  .calculator-area {
    padding: 14px;
  }

  .calculator-selector {
    flex-direction: column;
    align-items: stretch;
  }

  #calculator-type-select {
    max-width: none;
    width: 100%;
  }

  .input-row {
    flex-direction: column;
    gap: 0;
  }

  .input-row .input-group {
    margin-bottom: 14px;
  }

  .bg-orbit {
    top: 4%;
    right: -20%;
    opacity: 0.6;
  }
}
