/* ===== Reset & Root ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #0f766e;
  --primary-hover: #0d6b63;
  --primary-rgb: 15, 118, 110;
  --bg: #f9f7f4;
  --surface: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  --transition: 0.15s ease;
}

body {
  font-family: 'Outfit', 'BIZ UDPGothic', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  letter-spacing: -0.02em;
}

/* ===== Header ===== */
header {
  background: linear-gradient(135deg, #065f52 0%, #0f766e 60%, #14b8a6 100%);
  color: white;
  padding: 2.25rem 1.25rem 1.75rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 70%, rgba(255, 255, 255, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 15%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.header-inner {
  position: relative;
}

header h1 {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

header h1 .bi {
  font-size: 0.9em;
  vertical-align: -0.05em;
  margin-right: 0.2em;
}

.subtitle {
  margin-top: 0.4rem;
  font-size: 0.875rem;
  opacity: 0.85;
}

/* ===== Main ===== */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3.5rem;
}

/* ===== Ad units ===== */
.ad-unit {
  margin: 1.25rem 0;
}

/* ===== Params Section ===== */
.params-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.params-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.params-section h2 .bi {
  color: var(--primary);
}

/* ===== Slider Group ===== */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: center;
  gap: 1rem;
}

.slider-row label {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  cursor: default;
}

.param-sym {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  font-style: italic;
  min-width: 1.2rem;
}

.param-name {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.3;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  outline: none;
  cursor: pointer;
  min-height: 44px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(var(--primary-rgb), 0.4);
  transition: box-shadow var(--transition), transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.5);
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(var(--primary-rgb), 0.4);
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.25), 0 1px 4px rgba(var(--primary-rgb), 0.4);
}

.slider-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 3rem;
  text-align: right;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: #f0fdfb;
  border: 1px solid rgba(var(--primary-rgb), 0.15);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

/* ===== Resample Button ===== */
.resample-row {
  display: flex;
  justify-content: flex-end;
}

#resample-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9375rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
}

#resample-btn:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
  transform: translateY(-1px);
}

#resample-btn:active {
  background: #0a5c56;
  transform: translateY(0);
  box-shadow: none;
}

#resample-btn .bi {
  font-size: 1rem;
}

/* ===== Charts Section ===== */
.charts-section {
  margin-bottom: 1.5rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.chart-card canvas {
  width: 100% !important;
  max-height: 320px;
}

/* ===== Howto Section ===== */
.howto-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.howto-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--primary);
}

.howto-section h2:first-child {
  margin-top: 0;
}

.howto-section p {
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.8;
  margin-bottom: 0.5rem;
}

.howto-section dl {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 0.5rem;
}

.howto-section dt {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
}

.howto-section dd {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.75;
  margin-left: 1rem;
}

.howto-section ol {
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.howto-section ol li {
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.75;
}

/* ===== Affiliate Block ===== */
.affiliate-block {
  background: #f0fdfb;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.affiliate-block .bi {
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2.5rem 1.25rem;
  font-size: 0.85rem;
  color: #9ca3af;
  border-top: 1px solid var(--border);
}

footer a {
  color: #6b7280;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

footer p + p {
  margin-top: 0.5rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .slider-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .params-section,
  .chart-card,
  .howto-section {
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  main {
    padding: 1.25rem 1rem 3rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  header h1 {
    font-size: 1.25rem;
  }
}
