:root {
  color-scheme: light dark;
  font-family: 'Inter', 'PingFang TC', 'Microsoft JhengHei', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  background-color: #ecf2fb;
  color: #0f172a;
  --card-radius: 18px;
  --surface: #ffffff;
  --muted: #475569;
  --accent: #2563eb;
  --accent-2: #06b6d4;
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #f2f7ff, #e5ecf7 60%, #dfe7f3);
  min-height: 100vh;
  color: #0f172a;
}

.wrapper {
  width: min(1100px, 100% - 2.5rem);
  margin: 0 auto;
}

.page-header {
  background: linear-gradient(135deg, #091540, #142c88);
  color: #f8fafc;
  padding: 2.6rem 0 2rem;
  box-shadow: 0 18px 45px rgba(9, 21, 64, 0.55);
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 1px;
  color: white;
  box-shadow: 0 14px 35px rgba(6, 182, 212, 0.35);
}

.brand-name {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
}

.brand-tagline {
  margin: 0;
  color: rgba(248, 250, 252, 0.7);
  font-size: 0.9rem;
}

.nav-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: rgba(248, 250, 252, 0.85);
}

.badge {
  padding: 0.1rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.5);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.hero-content {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 2rem;
  align-items: center;
}

.page-header h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(2rem, 4vw, 2.9rem);
}

.hero-content p {
  color: rgba(248, 250, 252, 0.85);
}

.hero-highlights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.hero-highlights li {
  background: rgba(15, 23, 42, 0.4);
  border-radius: 16px;
  padding: 1rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.hero-highlights strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.hero-highlights span {
  font-size: 0.9rem;
  color: rgba(248, 250, 252, 0.7);
}

main {
  padding: 2.5rem 0 3.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--card-radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-value {
  margin: 0.15rem 0;
  font-size: 2rem;
  font-weight: 700;
  color: #111827;
}

.stat-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 1.4rem;
  align-items: start;
  margin-bottom: 1.5rem;
}

.layout-primary {
  display: grid;
  gap: 1.4rem;
}

.controls {
  background: var(--surface);
  border-radius: var(--card-radius);
  padding: 1.8rem;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 1.2rem;
}

.control-field label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.5rem;
}

#image-count {
  width: 100%;
}

.control-meta {
  margin-top: 0.4rem;
  font-size: 0.95rem;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.estimate {
  margin: 0;
  font-size: 1.05rem;
  color: #0f172a;
  font-weight: 600;
}

.buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

button {
  border: none;
  padding: 0.75rem 1.6rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#start-test {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 15px 30px rgba(37, 99, 235, 0.4);
}

#start-test:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ghost {
  background: transparent;
  border: 2px solid rgba(15, 23, 42, 0.18);
  color: #0f172a;
}

.info-panel {
  background: rgba(15, 23, 42, 0.8);
  color: #e2e8f0;
  border-radius: var(--card-radius);
  padding: 1.6rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.info-panel h3 {
  margin-top: 0;
  margin-bottom: 0.9rem;
}

.info-panel ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1.2rem;
  display: grid;
  gap: 0.8rem;
  font-size: 0.95rem;
  color: rgba(226, 232, 240, 0.9);
}

.info-meta {
  border-top: 1px solid rgba(248, 250, 252, 0.18);
  padding-top: 0.8rem;
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.75);
}

.info-value {
  font-size: 1.1rem;
  margin: 0.2rem 0 0;
  color: #f8fafc;
}

.status-panel {
  background: rgba(14, 116, 144, 0.85);
  color: #f8fafc;
  border-radius: 14px;
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 20px 40px rgba(13, 148, 136, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
  min-height: 120px;
}

.image-grid img {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 12px;
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.15);
  background: #e2e8f0;
  border: 2px solid rgba(15, 23, 42, 0.08);
  object-fit: cover;
}

@media (max-width: 580px) {
  .controls {
    padding: 1.25rem;
  }

  button {
    width: 100%;
    text-align: center;
  }

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

  .layout-primary {
    order: 2;
  }

  .info-panel {
    order: 1;
  }

  .top-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-meta {
    width: 100%;
    justify-content: space-between;
  }

  .hero-content {
    grid-template-columns: 1fr;
  }
}

.image-grid img.failed {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.35);
  filter: grayscale(0.8);
}
