:root {
  --primary: #4f6ef7;
  --primary-dark: #3b56d4;
  --primary-glow: rgba(79, 110, 247, 0.35);
  --success: #22c55e;
  --success-dark: #16a34a;
  --info: #06b6d4;
  --info-dark: #0891b2;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  background: radial-gradient(circle at 18% -10%, #e8ecfb 0%, #f0f2f8 50%, #eaeef6 100%);
  padding: 12px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  background: var(--surface);
  padding: 12px 16px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: containerIn 0.55s var(--ease-out) both;
}

@keyframes containerIn {
  from { opacity: 0; transform: translateY(14px) scale(0.992); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

h1 {
  text-align: center;
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(115deg, #3b56d4 0%, #4f6ef7 45%, #8b9cfb 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  flex-shrink: 0;
  animation: titleIn 0.7s var(--ease-out) both;
}

@keyframes titleIn {
  from { opacity: 0; letter-spacing: 6px; }
  to   { opacity: 1; letter-spacing: 0.5px; }
}

/* ====== 参数区 ====== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #fbfcfe, var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.param-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.param-row::-webkit-scrollbar {
  display: none;
  height: 0;
}

.controls label {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.2s ease;
}

.controls label:focus-within {
  color: var(--primary);
}

.controls label.is-hidden {
  display: none;
}

.controls input,
.controls select {
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
}

.controls input {
  width: 72px;
  text-align: center;
}

.controls select {
  width: auto;
  min-width: 90px;
  cursor: pointer;
}

.controls input:hover,
.controls select:hover {
  border-color: #a9b6cc;
}

.controls input:focus,
.controls select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: #fff;
}

.btn-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn-primary {
  position: relative;
  min-width: 140px;
  padding: 8px 28px;
  background: linear-gradient(135deg, #5b7bfa, var(--primary) 55%, var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.6px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.18s var(--ease-spring), box-shadow 0.25s ease, filter 0.2s ease;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.4), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(79, 110, 247, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.32);
  filter: brightness(1.05);
}

.btn-primary:hover:not(:disabled)::after {
  opacity: 1;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 3px 10px rgba(79, 110, 247, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:disabled {
  cursor: not-allowed;
  filter: grayscale(0.15) brightness(0.95);
}

.btn-primary.is-loading {
  padding-left: 40px;
}

.btn-primary.is-loading::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-top: -6.5px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ====== 预设按钮区 ====== */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.btn-preset {
  padding: 6px 14px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-preset:hover {
  background: var(--surface-3);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 110, 247, 0.15);
}

.btn-preset:active {
  transform: scale(0.97);
}

/* ====== 对比区 ====== */
.comparison-area {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.compare-box {
  background: linear-gradient(180deg, #ffffff, var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.55s var(--ease-out) both;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.compare-box:hover {
  box-shadow: var(--shadow);
  border-color: #d6ddea;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.compare-box h3 {
  margin: 0 0 6px 0;
  color: var(--text);
  text-align: center;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}

.compare-box h3::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), #8b9cfb);
  border-radius: 2px;
  transform: translateX(-50%);
  animation: underlineGrow 0.6s var(--ease-out) both;
}

@keyframes underlineGrow {
  from { width: 0; opacity: 0; }
  to   { width: 40px; opacity: 1; }
}

/* 统计信息 */
.compare-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
  font-size: 13px;
  margin-bottom: 6px;
  padding: 7px 10px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  overflow: hidden;
}

.stat-row {
  padding: 1px 0;
  line-height: 1.5;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: statIn 0.45s var(--ease-out) both;
}

.stat-row strong {
  color: var(--text);
  font-weight: 600;
}

@keyframes statIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.passenger-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 4px;
  padding: 2px 0 0;
  border-top: 1px dashed var(--border);
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

/* 乘客按钮网格 */
.compare-box .passenger-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 5px;
  flex-shrink: 0;
}

.passenger-btn {
  padding: 3px 6px;
  background: linear-gradient(135deg, #22d3ee, var(--info) 70%, var(--info-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(6, 182, 212, 0.2);
  transition: box-shadow 0.25s ease, filter 0.2s ease, background 0.25s ease;
}

.passenger-btn:hover {
  box-shadow: 0 4px 10px rgba(6, 182, 212, 0.4);
  filter: brightness(1.08);
}

.passenger-btn:active {
  box-shadow: 0 1px 4px rgba(6, 182, 212, 0.22);
  filter: brightness(0.96);
}

.passenger-btn.is-active {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  box-shadow: 0 3px 10px rgba(34, 197, 94, 0.5);
  filter: brightness(1.04);
  animation: btnPulse 0.9s ease-out;
}

@keyframes btnPulse {
  0%   { box-shadow: 0 3px 10px rgba(34, 197, 94, 0.5), 0 0 0 0   rgba(34, 197, 94, 0.55); }
  70%  { box-shadow: 0 3px 10px rgba(34, 197, 94, 0.5), 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 3px 10px rgba(34, 197, 94, 0.5), 0 0 0 0   rgba(34, 197, 94, 0); }
}

/* ====== 乘客详情卡片 ====== */
.compare-box .passenger-detail {
  padding: 6px 10px;
  font-size: 12px;
  background: linear-gradient(180deg, #fffefb 0%, #fffcf0 100%);
  border: 1px solid #f3e8c8;
  border-radius: var(--radius-sm);
  line-height: 1.45;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  color: #78350f;
  font-variant-numeric: tabular-nums;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
}

.compare-box .passenger-detail::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.compare-box .passenger-detail:empty {
  display: none;
}

.compare-box .passenger-detail strong {
  color: #92400e;
  font-size: 12.5px;
}

/* 详情卡片：两列网格 */
.compare-box .passenger-detail .detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
}

.compare-box .passenger-detail .detail-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  line-height: 1.45;
  padding: 1px 0;
  border-bottom: 1px dotted rgba(180, 130, 20, 0.15);
}

.compare-box .passenger-detail .detail-label {
  color: #a16207;
  white-space: nowrap;
}

.compare-box .passenger-detail .detail-value {
  color: #78350f;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.passenger-detail.slide-in {
  animation: detailSlideIn 0.38s var(--ease-out) both;
}

.passenger-detail.slide-out {
  animation: detailSlideOut 0.16s var(--ease-in) both;
  pointer-events: none;
}

@keyframes detailSlideIn {
  from { opacity: 0; transform: translateX(22px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes detailSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-16px); }
}

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .comparison-area { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}