:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1c2321;
  --muted: #5b6763;
  --line: #dfe4e1;
  --accent: #0f766e;
  --accent-soft: #e3f3f0;
  --accent-text: #ffffff;
  --warn: #b45309;
  --error: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 22, 0.06), 0 4px 16px rgba(16, 24, 22, 0.05);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1b2120;
    --text: #e7ecea;
    --muted: #a3b0ac;
    --line: #2e3735;
    --accent: #2dd4bf;
    --accent-soft: #163330;
    --accent-text: #06201d;
    --warn: #fbbf24;
    --error: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
}

img {
  max-width: 100%;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 8px;
  background: var(--surface);
  padding: 4px 8px;
  z-index: 10;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}

.header-link {
  font-size: 0.9rem;
  text-decoration: none;
}

main {
  padding-top: 20px;
  padding-bottom: 48px;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.4;
  margin: 8px 0 8px;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.5;
  margin: 36px 0 12px;
  padding-left: 10px;
  border-left: 4px solid var(--accent);
}

h3 {
  font-size: 1.05rem;
  margin: 24px 0 8px;
}

.lead {
  color: var(--muted);
  margin-top: 0;
}

.crumbs {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.hero {
  padding: 12px 0 4px;
}

.hero h1 {
  font-size: 1.9rem;
}

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

.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.cards a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}

.cards a:hover,
.cards a:focus-visible {
  border-color: var(--accent);
}

.cards strong {
  display: block;
  color: var(--accent);
  font-size: 1.05rem;
}

.cards span {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 4px;
}

.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px;
  margin: 20px 0;
}

.tool form {
  display: grid;
  gap: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0;
}

.tabs legend {
  font-weight: 700;
  margin-bottom: 6px;
  padding: 0;
}

.tabs label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
}

.tabs label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.field > span:first-child {
  font-weight: 700;
  font-size: 0.95rem;
}

.field small {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.input-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 46px;
  min-width: 0;
}

textarea {
  min-height: 200px;
  line-height: 1.7;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: 20px;
  height: 20px;
}

button,
.btn {
  font: inherit;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 12px 20px;
  cursor: pointer;
  min-height: 46px;
}

button.secondary {
  color: var(--accent);
  background: var(--accent-soft);
}

.result {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.result .big {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.3;
  margin: 0 0 6px;
  color: var(--text);
}

.result .big small {
  font-size: 1rem;
  font-weight: 700;
}

.result dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 8px 0 0;
}

.result dt {
  color: var(--muted);
}

.result dd {
  margin: 0;
  font-weight: 700;
  word-break: keep-all;
}

.result .note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 0 0;
}

.error {
  color: var(--error);
  font-weight: 700;
  margin: 12px 0 0;
}

.error:empty {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  margin: 12px 0;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  background: var(--surface);
}

th,
td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: right;
  white-space: nowrap;
}

th {
  background: var(--accent-soft);
  text-align: center;
}

td.l {
  text-align: left;
}

tr.current td {
  background: var(--accent-soft);
  font-weight: 700;
}

.aff {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 20px 0;
  background: var(--surface);
}

.aff-head {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.pr {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--muted);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 6px;
  line-height: 1.5;
}

.aff ul {
  margin: 0;
  padding-left: 1.2em;
}

.product {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 20px 0;
  background: var(--accent-soft);
}

.product-head {
  margin: 0 0 6px;
  font-weight: 700;
}

.product ul {
  margin: 0;
  padding-left: 1.2em;
}

.product-price {
  color: var(--muted);
  font-size: 0.9rem;
}

.product-note {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.guide,
.prose {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 18px 18px;
}

.guide h2:first-child,
.prose h2:first-child {
  margin-top: 20px;
}

.formula {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
}

.related h2 {
  margin-top: 36px;
}

.updated {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 24px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 0 28px;
  font-size: 0.88rem;
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.ad-notice {
  margin: 0 0 8px;
}

.copy {
  margin: 12px 0 0;
}

@media (min-width: 640px) {
  .tool {
    padding: 24px;
  }

  h1 {
    font-size: 1.8rem;
  }
}
