/* ========================================
   基本
======================================== */

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;

  color: #1f2937;

  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", sans-serif;

  background: #f4f6f8;
}

button,
input {
  font: inherit;
}

/* ========================================
   全体
======================================== */

.page-wrapper {
  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
}

main {
  width: min(92%, 760px);

  margin-top: 40px;
  padding: 36px;

  border: 1px solid #e5e7eb;
  border-radius: 20px;

  background: #ffffff;

  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.06),
    0 2px 8px rgba(0, 0, 0, 0.03);
}

/* ========================================
   ヘッダー
======================================== */

.tool-header {
  margin-bottom: 32px;

  text-align: center;
}

.brand {
  margin: 0 0 8px;

  color: #6b7280;

  font-size: 13px;
  font-weight: 600;

  letter-spacing: 0.08em;
}

h1 {
  margin: 0;

  color: #111827;

  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;

  line-height: 1.3;
}

.tool-intro {
  max-width: 560px;

  margin: 14px auto 0;

  color: #6b7280;

  font-size: 15px;
  line-height: 1.8;
}

/* ========================================
   計算エリア
======================================== */

.calculator {
  padding: 28px;

  border: 1px solid #e5e7eb;
  border-radius: 16px;

  background: #fafafa;
}

.calculator h2 {
  margin: 0 0 22px;

  color: #111827;

  font-size: 20px;
  text-align: center;
}

/* ========================================
   入力欄
======================================== */

.input-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 18px;
}

.input-item {
  display: block;
}

.input-label {
  display: block;

  margin-bottom: 7px;

  color: #374151;

  font-size: 14px;
  font-weight: 600;
}

.input-wrap {
  position: relative;

  display: flex;
  align-items: center;
}

.input-wrap input {
  width: 100%;

  padding: 13px 52px 13px 14px;

  color: #111827;

  font-size: 16px;

  border: 1px solid #d1d5db;
  border-radius: 10px;

  outline: none;

  background: #ffffff;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.input-wrap input:focus {
  border-color: #2563eb;

  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-wrap input::placeholder {
  color: #9ca3af;
}

.unit {
  position: absolute;

  right: 14px;

  color: #6b7280;

  font-size: 14px;

  pointer-events: none;
}

/* ========================================
   ボタン
======================================== */

.calculate-button,
.reset-button {
  width: 100%;

  border: 0;
  border-radius: 10px;

  cursor: pointer;

  transition:
    transform 0.1s ease,
    filter 0.2s ease,
    background 0.2s ease;
}

.calculate-button {
  margin-top: 24px;

  padding: 15px 20px;

  color: #ffffff;

  font-size: 16px;
  font-weight: 700;

  background: #2563eb;

  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.22);
}

.calculate-button:hover {
  background: #1d4ed8;
}

.calculate-button:active {
  transform: translateY(1px);
}

.reset-button {
  margin-top: 10px;

  padding: 11px 20px;

  color: #6b7280;

  font-size: 13px;
  font-weight: 600;

  background: transparent;
}

.reset-button:hover {
  color: #374151;

  background: #f3f4f6;
}

/* ========================================
   計算結果
======================================== */

.result-area {
  margin-top: 28px;
  padding: 28px;

  border: 1px solid #e5e7eb;
  border-radius: 16px;

  background: #ffffff;
}

.result-area h2 {
  margin: 0 0 22px;

  color: #111827;

  font-size: 20px;
  text-align: center;
}

.result-grid {
  display: grid;

  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 14px;
}

.result-card {
  min-height: 115px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  padding: 18px 12px;

  text-align: center;

  border: 1px solid #e5e7eb;
  border-radius: 12px;

  background: #f9fafb;
}

.result-label {
  margin-bottom: 7px;

  color: #6b7280;

  font-size: 13px;
  font-weight: 600;
}

.result-value {
  color: #111827;

  font-size: 28px;
  font-weight: 800;

  line-height: 1.2;
}

.result-unit {
  margin-top: 4px;

  color: #6b7280;

  font-size: 12px;
}

/* 横幅いっぱい */

.result-card.wide {
  grid-column: 1 / -1;
}

/* ========================================
   1日の摂取回数
======================================== */

.daily-serving-card {
  padding-top: 22px;
  padding-bottom: 22px;
}

.daily-serving-selector {
  display: flex;
  justify-content: center;
  align-items: center;

  gap: 18px;

  margin: 10px 0 16px;
}

.serving-change-button {
  width: 44px;
  height: 44px;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 0;

  color: #2563eb;

  font-size: 24px;
  font-weight: 700;
  line-height: 1;

  border: 1px solid #d1d5db;
  border-radius: 10px;

  background: #ffffff;

  cursor: pointer;

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.1s ease;
}

.serving-change-button:hover:not(:disabled) {
  color: #1d4ed8;

  border-color: #2563eb;

  background: #eff6ff;
}

.serving-change-button:active:not(:disabled) {
  transform: translateY(1px);
}

.serving-change-button:disabled {
  color: #c4c8cf;

  border-color: #e5e7eb;

  background: #f3f4f6;

  cursor: not-allowed;
}

.daily-serving-value {
  min-width: 110px;

  color: #111827;

  font-size: 19px;
  font-weight: 700;

  text-align: center;
}

.daily-days-result {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ========================================
   エラー
======================================== */

.error-message {
  min-height: 20px;

  margin: 16px 0 0;

  color: #dc2626;

  font-size: 13px;
  font-weight: 600;

  text-align: center;
}

/* ========================================
   説明コンテンツ
======================================== */

.content-section {
  margin-top: 28px;
  padding: 24px;

  border: 1px solid #e5e7eb;
  border-radius: 14px;

  background: #ffffff;
}

.content-section h2 {
  margin: 0 0 16px;

  color: #111827;

  font-size: 19px;
  text-align: center;
}

.content-section h3 {
  margin: 22px 0 7px;

  color: #1f2937;

  font-size: 15px;
}

.content-section p {
  margin: 9px 0;

  color: #4b5563;

  font-size: 14px;
  line-height: 1.8;
}

/* ========================================
   フッター
======================================== */

.site-footer {
  width: min(92%, 760px);

  margin-top: 30px;
  padding: 24px 16px 36px;

  color: #9ca3af;

  font-size: 12px;
  text-align: center;
}

.site-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;

  gap: 10px 18px;

  margin-bottom: 12px;
}

.site-footer a {
  color: #6b7280;

  text-decoration: underline;
}

.site-footer a:hover {
  color: #2563eb;
}

.site-footer p {
  margin: 0;
}

/* ========================================
   スマートフォン
======================================== */

@media (max-width: 600px) {
  main {
    width: 94%;

    margin-top: 20px;
    padding: 22px 16px;

    border-radius: 16px;
  }

  .tool-header {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 27px;
  }

  .tool-intro {
    font-size: 14px;
  }

  .calculator,
  .result-area,
  .content-section {
    padding: 20px 16px;
  }

  .input-grid {
    grid-template-columns: 1fr;

    gap: 15px;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;

    gap: 10px;
  }

  .result-card {
    min-height: 105px;

    padding: 14px 8px;
  }

  .result-label {
    font-size: 12px;
  }

  .result-value {
    font-size: 23px;
  }

  .daily-serving-card {
    padding: 18px 10px;
  }

  .daily-serving-selector {
    gap: 14px;

    margin: 9px 0 14px;
  }

  .serving-change-button {
    width: 42px;
    height: 42px;

    font-size: 22px;
  }

  .daily-serving-value {
    min-width: 96px;

    font-size: 17px;
  }

  .content-section p {
    font-size: 13px;
  }

  .site-footer {
    width: 94%;

    padding-bottom: 28px;
  }
}

/* ========================================
   かなり狭い画面
======================================== */

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

  .daily-serving-selector {
    gap: 10px;
  }
}
