:root {
  --color-bg: #f6f8fa;
  --color-text: #1f2933;
  --color-primary: #ea580c;
  --color-primary-dark: #c2410c;
  --accent2: #0d9488;
  --grad: linear-gradient(120deg, var(--color-primary), var(--accent2));
  --btn-c1: var(--color-primary);
  --btn-c2: var(--accent2);
  --btn-grad: linear-gradient(120deg, var(--btn-c1), var(--btn-c2));
  --color-card: #ffffff;
  --color-border: #d7dde3;
  --muted: #6b7280;
  --hero-grid: rgba(20, 20, 40, 0.05);
  --radius: 10px;
}

:root[data-theme="dark"] {
  --color-bg: #121214;
  --color-text: #ececee;
  --color-primary: #fb923c;
  --accent2: #2dd4bf;
  /* ボタンの塗りは文字用のaccentよりトーンを落として、暗い背景で発光しすぎないようにする */
  --btn-c1: #ea580c;
  --btn-c2: #0d9488;
  --color-card: #1c1c20;
  --color-border: #2c2c31;
  --muted: #9a9aa2;
  --hero-grid: rgba(255, 255, 255, 0.06);
}
:root[data-theme="dark"] .tab {
  background: #26262c;
  color: #9a9aa2;
}
:root[data-theme="dark"] .input-group input,
:root[data-theme="dark"] .input-group select,
:root[data-theme="dark"] #swap-btn {
  background: #1c1c20;
  color: #ececee;
}
:root[data-theme="dark"] #swap-btn:hover {
  background: #26262c;
}
:root[data-theme="dark"] .result {
  background: #2a1f16;
}
:root[data-theme="dark"] .ad-slot {
  background: #1c1c20;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background-color: var(--color-bg);
  background-image:
    radial-gradient(circle, var(--hero-grid) 1px, transparent 1px),
    radial-gradient(900px circle at 15% -10%, color-mix(in srgb, var(--color-primary) 12%, transparent), transparent 55%),
    radial-gradient(800px circle at 100% 10%, color-mix(in srgb, var(--accent2) 9%, transparent), transparent 55%);
  background-size: 22px 22px, auto, auto;
  background-attachment: fixed;
  color: var(--color-text);
  line-height: 1.7;
}

header { padding: 2rem 1rem 1rem; text-align: center; }
header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { color: var(--muted); margin: 0; }

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.calculator {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab {
  flex: 1;
  padding: 0.7rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  color: #4b5563;
}

.tab.active {
  background: var(--btn-grad);
  color: #fff;
  border-color: transparent;
}

.convert-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr;
  gap: 0.8rem;
  align-items: end;
}

.input-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.input-group input,
.input-group select {
  width: 100%;
  padding: 0.7rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
}

.swap-wrap { display: flex; justify-content: center; }

#swap-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}
#swap-btn:hover { background: #f3f4f6; }

.result {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #fff7ed;
  border-radius: 8px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--color-primary-dark);
}

.ad-slot {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef1f4;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1.5rem 0;
}

.info {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.info h2 { font-size: 1.2rem; margin-top: 1.5rem; }
.info h2:first-child { margin-top: 0; }
.info ul { padding-left: 1.3rem; }

.formula {
  background: #fff7ed;
  border-radius: 6px;
  padding: 0.7rem 1rem;
  font-weight: bold;
  text-align: center;
}

.note { font-size: 0.85rem; color: var(--muted); }

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  header h1 { font-size: 1.4rem; }
  .calculator, .info { padding: 1rem; }
  .convert-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "value value"
      "from to"
      "swap swap";
  }
  .convert-row .input-group:nth-child(1) { grid-area: value; }
  .convert-row .input-group:nth-child(2) { grid-area: from; }
  .convert-row .swap-wrap { grid-area: swap; }
  .convert-row .input-group:nth-child(4) { grid-area: to; }
}

.site-nav {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  box-sizing: border-box;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  color: inherit;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.site-nav a:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
}
