:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-elev: rgba(255, 255, 255, 0.9);
  --text: #111827;
  --muted: #667085;
  --border: #d7dee6;
  --brand: #0f766e;
  --brand-2: #2563eb;
  --accent: #f97316;
  --pos: #0f766e;
  --neg: #dc2626;
  --grad: linear-gradient(135deg, #0f766e 0%, #2563eb 58%, #f97316 100%);
  --shadow: 0 18px 48px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
  font-family: "Inter", "Helvetica Neue", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(37, 99, 235, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(244, 247, 248, 0.95), rgba(244, 247, 248, 0.9));
  background-size: 48px 48px, 48px 48px, 100% 100%;
  color: var(--text);
  line-height: 1.65;
}

header {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(34px, 8vw, 72px) 0 22px;
}

h1 {
  max-width: 720px;
  margin: 0;
  background: var(--grad);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.08;
}

header p {
  max-width: 56ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

main {
  display: grid;
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 48px;
  gap: 16px;
}

.panel {
  padding: clamp(18px, 4vw, 28px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elev);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--grad);
}

.panel h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
  letter-spacing: 0;
}

.formula-box {
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(37, 99, 235, 0.06), rgba(249, 115, 22, 0.05)),
    var(--surface);
  color: var(--muted);
  font-size: 0.92rem;
}

.formula-box p {
  margin: 0.35rem 0;
}

.formula-box strong {
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand-2);
}

output {
  justify-self: end;
  min-width: 88px;
  padding: 4px 8px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-2);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
}

.small input[type="number"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.small input[type="number"]:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.46);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.result-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.result-card h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.value {
  min-height: 1.35em;
  font-size: clamp(1.8rem, 5vw, 2.65rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1.1;
  transition: color 0.3s ease;
}

footer {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 38px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1118;
    --surface: #111923;
    --surface-elev: rgba(17, 25, 35, 0.88);
    --text: #eef4f8;
    --muted: #91a1af;
    --border: #263545;
  }

  body {
    background:
      linear-gradient(rgba(96, 165, 250, 0.08) 1px, transparent 1px),
      linear-gradient(90deg, rgba(45, 212, 191, 0.07) 1px, transparent 1px),
      linear-gradient(180deg, rgba(11, 17, 24, 0.97), rgba(11, 17, 24, 0.94));
    background-size: 48px 48px, 48px 48px, 100% 100%;
  }

  .panel,
  .result-card,
  .formula-box,
  output,
  .small input[type="number"] {
    box-shadow: none;
  }
}

@media (max-width: 720px) {
  .result-grid {
    grid-template-columns: 1fr;
  }
}
