:root {
  --bg: #f7faf6;
  --bg-warm: #fffaf2;
  --ink: #213029;
  --muted: #7b8881;
  --line: #e5ebe6;
  --card: rgba(255, 255, 255, .92);
  --mint: #e8f5ed;
  --mint-2: #d7efe1;
  --green: #3e7c62;
  --green-deep: #24523f;
  --peach: #fff0df;
  --peach-deep: #d99556;
  --danger: #ae514b;
  --shadow: 0 24px 70px rgba(56, 88, 70, .10);
  --shadow-soft: 0 12px 34px rgba(56, 88, 70, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #fbfdf9 0%, #f7fbf7 42%, #fbf8f2 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { display: block; }

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}
.ambient-a { width: 420px; height: 420px; top: 40px; left: -250px; background: rgba(215, 239, 225, .62); }
.ambient-b { width: 340px; height: 340px; top: 360px; right: -220px; background: rgba(255, 232, 204, .46); }
.ambient-c { width: 270px; height: 270px; top: 900px; left: -170px; background: rgba(226, 240, 248, .45); }

.site-header {
  width: min(1120px, calc(100% - 36px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: -.035em;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--green-deep);
  border: 1px solid rgba(62,124,98,.12);
  border-radius: 13px;
  background: rgba(255,255,255,.8);
  box-shadow: 0 8px 20px rgba(54, 93, 72, .06);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.hero {
  width: min(620px, calc(100% - 28px));
  margin: 0 auto;
  padding: 48px 0 24px;
}
.hero-copy { text-align: center; margin-bottom: 26px; }
.hero-symbol {
  position: relative;
  width: 54px;
  height: 54px;
  margin: 0 auto 13px;
  display: grid;
  place-items: center;
  color: var(--green-deep);
}
.hero-symbol .symbol-ring {
  position: absolute;
  inset: 0;
  border-radius: 18px 18px 22px 18px;
  background: linear-gradient(145deg, #e8f6ed, #f8f2df);
  transform: rotate(-7deg);
}
.hero-symbol svg { position: relative; width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1 {
  margin: 0;
  font-size: clamp(48px, 8vw, 70px);
  line-height: 1.03;
  font-weight: 950;
  letter-spacing: -.07em;
}
.hero-lead {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(15px, 2vw, 17px);
  line-height: 1.8;
  font-weight: 650;
}

.calculator-shell { position: relative; }
.calculator-shell::before {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: -12px;
  height: 70%;
  border-radius: 28px;
  background: rgba(224, 240, 229, .55);
  filter: blur(1px);
  z-index: -1;
}
.calculator-card {
  position: relative;
  overflow: hidden;
  padding: 23px 24px 22px;
  border: 1px solid rgba(224, 233, 226, .95);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.calculator-card::after {
  content: "";
  position: absolute;
  top: -80px;
  right: -65px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: rgba(232,245,237,.7);
  pointer-events: none;
}

.input-group {
  position: relative;
  z-index: 1;
  padding: 3px 0 22px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.input-group-last { margin-bottom: 0; padding-bottom: 7px; border-bottom: 0; }
.field-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
}
.field-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: var(--green-deep);
  background: linear-gradient(145deg, var(--mint), #f7fbf8);
  border: 1px solid rgba(62,124,98,.08);
}
.field-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.field-title-row h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.field-title-row p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }

.value-line {
  min-height: 60px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #dfe8e1;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.value-line:focus-within {
  border-color: rgba(62,124,98,.5);
  box-shadow: 0 0 0 4px rgba(62,124,98,.08);
}
.big-input {
  min-width: 0;
  width: 100%;
  padding: 11px 17px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 26px;
  font-weight: 950;
  letter-spacing: -.04em;
}
.unit-select,
.unit-display {
  min-width: 82px;
  border: 0;
  border-left: 1px solid var(--line);
  background: #f8fbf8;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}
.unit-select { padding: 0 13px; outline: 0; }
.unit-display { display: grid; place-items: center; padding: 0 16px; }

.quick-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.quick-chip {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #e3eae5;
  border-radius: 11px;
  background: rgba(255,255,255,.9);
  color: #627169;
  font-size: 12px;
  font-weight: 850;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.quick-chip:hover { transform: translateY(-1px); border-color: rgba(62,124,98,.32); }
.quick-chip.is-selected { border-color: transparent; background: var(--mint); color: var(--green-deep); }
.auto-unit-note { margin: 8px 1px 0; color: #919b95; font-size: 10.5px; }

.frequency-main { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.freq-btn {
  min-height: 46px;
  border: 1px solid #e1e9e3;
  border-radius: 14px;
  background: #fff;
  color: #5a6961;
  font-size: 13px;
  font-weight: 900;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.freq-btn:hover { transform: translateY(-1px); }
.freq-btn.is-active {
  border-color: var(--green);
  background: linear-gradient(145deg, #4b866d, #3a755d);
  color: #fff;
  box-shadow: 0 9px 20px rgba(62,124,98,.18);
}
.advanced-toggle {
  width: 100%;
  margin-top: 8px;
  padding: 8px 4px 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--green-deep);
  font-size: 11.5px;
  font-weight: 850;
}
.toggle-arrow { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .18s ease; }
.advanced-toggle[aria-expanded="true"] .toggle-arrow { transform: rotate(180deg); }
.advanced-frequency {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #f8faf8;
}
.advanced-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.advanced-tab {
  padding: 9px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.advanced-tab.is-active { background: #fff; color: var(--green-deep); box-shadow: var(--shadow-soft); }
.advanced-panel { padding: 10px 2px 2px; text-align: center; }
.inline-control { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: #5b6961; font-size: 13px; font-weight: 850; }
.inline-control input { width: 74px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: 0; text-align: center; color: var(--ink); font-weight: 900; }


.primary-btn {
  width: 100%;
  min-height: 60px;
  margin-top: 17px;
  padding: 10px 10px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(135deg, #4b856c, #2f664f);
  color: #fff;
  font-weight: 950;
  letter-spacing: -.01em;
  box-shadow: 0 15px 30px rgba(45,101,78,.20);
  transition: transform .16s ease, box-shadow .16s ease;
}

.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 19px 34px rgba(45,101,78,.24); }
.primary-btn:active { transform: translateY(0); }
.btn-circle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: rgba(255,255,255,.14);
}
.btn-circle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.form-error { min-height: 18px; margin: 8px 2px -5px; color: var(--danger); font-size: 12px; font-weight: 750; }

.result-card {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  padding: 26px;
  border-radius: 27px;
  color: #fff;
  background: linear-gradient(145deg, #346c55 0%, #24513f 100%);
  box-shadow: 0 22px 55px rgba(37,75,61,.20);
  animation: reveal .35s ease both;
}
.result-glow { position: absolute; width: 200px; height: 200px; right: -70px; top: -95px; border-radius: 50%; background: rgba(255,237,204,.11); }
@keyframes reveal { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
.result-top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-kicker { color: rgba(255,255,255,.68); font-size: 11.5px; font-weight: 850; letter-spacing: .04em; }
.result-today { color: rgba(255,255,255,.52); font-size: 10.5px; }
.result-main { position: relative; display: flex; align-items: baseline; gap: 7px; margin-top: 14px; }
.result-prefix { color: rgba(255,255,255,.76); font-size: 17px; font-weight: 850; }
.result-number { font-size: clamp(60px, 15vw, 86px); line-height: .9; font-weight: 950; letter-spacing: -.065em; }
.result-unit { font-size: 22px; font-weight: 900; }
.result-date { position: relative; margin: 15px 0 0; font-size: clamp(20px, 4vw, 25px); line-height: 1.35; font-weight: 950; letter-spacing: -.03em; }
.result-stats { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.result-stat { min-height: 69px; display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid rgba(255,255,255,.10); border-radius: 15px; background: rgba(255,255,255,.07); }
.result-stat-icon { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.08); }
.result-stat-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.result-stat-copy { min-width: 0; }
.result-stat-copy small { display: block; margin-bottom: 4px; color: rgba(255,255,255,.55); font-size: 9.5px; }
.result-stat-copy strong { font-size: 14px; }
.result-actions { position: relative; display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }
.edit-btn { padding: 10px 14px; border-radius: 999px; font-size: 11.5px; font-weight: 900; }
.edit-btn { border: 1px solid rgba(255,255,255,.18); background: transparent; color: rgba(255,255,255,.82); }

.popular-section {
  width: min(760px, calc(100% - 28px));
  margin: 48px auto 0;
  padding: 44px 0 74px;
}

.section-heading { max-width: 620px; margin: 0 auto 22px; text-align: center; }
.section-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--green-deep);
  background: linear-gradient(145deg, #eaf6ee, #fff4e6);
}
.section-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.section-heading h2 { margin: 0; font-size: clamp(26px, 4.8vw, 38px); line-height: 1.22; letter-spacing: -.045em; }
.section-heading p { margin: 11px auto 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.popular-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.popular-card {
  min-height: 92px;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(224,232,226,.95);
  border-radius: 18px;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(57,86,70,.04);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.popular-card:hover { transform: translateY(-2px); border-color: rgba(62,124,98,.26); background: #fff; box-shadow: var(--shadow-soft); }
.popular-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 14px; font-size: 21px; }
.popular-icon-rice { background: #fff5de; }
.popular-icon-coffee { background: #f5ece4; }
.popular-icon-protein { background: #edf5f8; }
.popular-icon-shampoo { background: #eff4ff; }
.popular-icon-toner { background: #ebf8fb; }
.popular-icon-detergent { background: #eef7ed; }
.popular-copy { min-width: 0; }
.popular-copy strong { display: block; margin-bottom: 3px; font-size: 15px; }
.popular-copy small { display: block; color: var(--muted); font-size: 10.8px; line-height: 1.45; }
.popular-arrow { color: #a4afa8; font-size: 16px; }

footer {
  padding: 22px 18px 34px;
  border-top: 1px solid var(--line);
  color: #8f9993;
  text-align: center;
  font-size: 10.5px;
  line-height: 1.7;
}
footer p { margin: 2px 0; }

@media (max-width: 640px) {
  .site-header { width: min(100% - 24px, 1120px); min-height: 62px; }
  .brand { font-size: 14px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 11px; }
  .hero { width: min(100% - 20px, 620px); padding-top: 31px; }
  .hero-symbol { width: 48px; height: 48px; margin-bottom: 10px; }
  h1 { font-size: clamp(44px, 14vw, 58px); }
  .hero-lead { margin-top: 13px; font-size: 14px; }
  .hero-copy { margin-bottom: 21px; }
  .calculator-card { padding: 18px; border-radius: 22px; }
  .field-title-row { margin-bottom: 11px; }
  .field-icon { width: 35px; height: 35px; border-radius: 12px; }
  .input-group { padding-bottom: 19px; margin-bottom: 18px; }
  .big-input { padding-left: 14px; font-size: 23px; }
  .unit-select, .unit-display { min-width: 74px; }
  .frequency-main { gap: 6px; }
  .freq-btn { min-height: 44px; font-size: 12px; }
  .result-card { padding: 21px; border-radius: 23px; }
  .popular-section { width: min(100% - 20px, 760px); margin-top: 34px; padding-top: 38px; }
  .popular-grid { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .calculator-card { padding: 16px; }
  .frequency-main { grid-template-columns: 1fr; }
  .result-stats { grid-template-columns: 1fr; }
  .section-heading h2 { font-size: 25px; }
}

/* v4: public header / footer navigation */
.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.header-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.76);
  color: var(--green-deep);
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .015em;
  box-shadow: 0 8px 20px rgba(54, 93, 72, .04);
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.header-link:hover {
  transform: translateY(-1px);
  border-color: rgba(62,124,98,.28);
  background: #fff;
}
.tools-link {
  padding: 8px 13px;
  border-radius: 999px;
}
.lang-link {
  width: 38px;
  padding: 0;
  border-radius: 12px;
  background: var(--mint);
  border-color: rgba(62,124,98,.10);
}

.site-footer {
  padding: 28px 18px 34px;
  border-top: 1px solid var(--line);
  color: #8f9993;
  text-align: center;
  font-size: 10.5px;
  line-height: 1.7;
}
.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.footer-nav a {
  color: #728078;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  transition: color .14s ease, border-color .14s ease, background .14s ease;
}
.footer-nav a:hover { color: var(--green-deep); }
.site-footer p { margin: 2px 0; }
.footer-note { color: #929c96; }
.footer-copy { color: #a0a9a4; }

@media (max-width: 640px) {
  .header-actions { gap: 6px; }
  .header-link { min-height: 34px; font-size: 9.5px; }
  .tools-link { padding: 7px 10px; }
  .lang-link { width: 34px; border-radius: 11px; }
}

@media (max-width: 470px) {
  .site-header { gap: 8px; }
  .brand { gap: 7px; }
  .brand > span:last-child { font-size: 12px; }
  .brand-mark { width: 30px; height: 30px; }
  .header-actions { gap: 5px; }
  .tools-link { padding: 7px 8px; font-size: 8.5px; }
  .lang-link { width: 32px; font-size: 9px; }
}

@media (max-width: 390px) {
  .brand > span:last-child { display: none; }
  .site-header { width: min(100% - 20px, 1120px); }
  .footer-nav { gap: 9px 13px; }
}


/* English top-page adjustments */
html[lang="en"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
html[lang="en"] h1 {
  font-size: clamp(44px, 7.2vw, 64px);
  letter-spacing: -.055em;
}
html[lang="en"] .hero-lead {
  line-height: 1.65;
}
html[lang="en"] .field-title-row h2 {
  letter-spacing: -.018em;
}
html[lang="en"] .freq-btn {
  padding-left: 8px;
  padding-right: 8px;
}
html[lang="en"] .popular-copy small {
  font-size: 10.5px;
}
.popular-icon-conditioner { background: #f4efff; }
.popular-icon-toilet { background: #fff5e7; }

@media (max-width: 470px) {
  html[lang="en"] .brand > span:last-child { font-size: 11px; }
}
