/* ============================================
   Health Calc — Shared Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700;900&display=swap');

:root {
  --accent:     #9333ea;
  --accent2:    #7c3aed;
  --accent3:    #a855f7;
  --accent-light: rgba(147,51,234,0.15);
  --text:       #1e293b;
  --text-sub:   #475569;
  --text-dim:   #94a3b8;
  --text-muted: #64748b;
  --gold:       #d97706;
  --red:        #dc2626;
  --green:      #219234;
  --radius:     1.25rem;
  --radius-sm:  0.625rem;
  --shadow-card: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-dark: 0 10px 40px rgba(15,23,42,0.25), 0 0 0 1px rgba(147,51,234,0.08), inset 0 1px 0 rgba(255,255,255,0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  background: linear-gradient(160deg, #f3e8ff 0%, #d8b4fe 35%, #e9d5ff 65%, #faf5ff 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem 5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Site Header ── */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0 4px;
  margin-bottom: 4px;
}
.site-logo {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.8125rem;
  color: rgba(109,40,217,0.85);
  text-decoration: none;
  letter-spacing: 0.1em;
  font-weight: 500;
  transition: color 0.2s;
}
.site-logo:hover { color: var(--accent); }
.page-name {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.8125rem;
  color: rgba(109,40,217,0.7);
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* ── App Header ── */
.app-header {
  margin-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.app-tag {
  display: inline-flex;
  align-items: center;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  color: var(--accent);
  background: rgba(22,163,74,0.08);
  border: 1px solid rgba(22,163,74,0.2);
  border-radius: 4px;
  padding: 3px 8px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.app-title {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}
.app-desc {
  flex-basis: 100%;
  font-size: 0.875rem;
  color: var(--text-sub);
  font-weight: 300;
  margin: 2px 0 0;
}

/* ── Card ── */
.card {
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}
.card-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

/* ── Form Elements ── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
label .unit { font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .prefix,
.input-wrap .suffix {
  position: absolute;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}
.input-wrap .prefix { left: 14px; }
.input-wrap .suffix { right: 14px; }

input[type="number"],
input[type="text"],
input[type="time"],
select {
  width: 100%;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(134,239,172,0.5);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
  min-height: 48px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04);
}
input[type="time"] {
  font-size: 2.4rem;
  font-weight: 200;
  letter-spacing: 0.08em;
  padding: 8px 14px;
  text-align: center;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input::placeholder { color: rgba(100,116,139,0.4); }
input:focus, select:focus {
  border-color: var(--accent3);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.12);
  background: rgba(255,255,255,0.95);
}
.has-prefix input { padding-left: 32px; }
.has-suffix input { padding-right: 36px; }
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 380px) {
  .fields-grid { grid-template-columns: 1fr; }
}

/* ── Button ── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 9999px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.12s ease;
  margin-top: 1.25rem;
  min-height: 52px;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, #9333ea 0%, #7c3aed 50%, #a855f7 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(22,163,74,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
  border: 1px solid rgba(147,51,234,0.25);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(22,163,74,0.5), inset 0 1px 0 rgba(255,255,255,0.15); }

/* ── Result Panel ── */
.result {
  display: none;
  background: linear-gradient(145deg, #0a1f0f 0%, #14311e 55%, #1a4228 100%);
  border: 1px solid rgba(147,51,234,0.15);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-dark);
  animation: fadeSlideIn 0.3s ease;
}
.result.visible { display: block; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-main {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(147,51,234,0.15);
}
.result-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(148,163,184,0.9);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.result-value {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 2.4rem;
  font-weight: 200;
  color: #ffffff;
  letter-spacing: 0.08em;
  line-height: 1;
}
.result-unit {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(147,51,234,0.7);
  margin-left: 6px;
}
.result-rows { display: flex; flex-direction: column; gap: 10px; }
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
.result-row .rr-label { color: rgba(148,163,184,0.8); }
.result-row .rr-val {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-weight: 500;
  color: #cbd5e1;
}
.result-row .rr-val.highlight { color: #4ade80; }
.result-row .rr-val.gold      { color: #fbbf24; }
.result-row .rr-val.red       { color: #f87171; }
.result-row .rr-val.green     { color: #c4b5fd; }
.result-divider { height: 1px; background: rgba(147,51,234,0.12); margin: 4px 0; }

/* ── Error ── */
.error-msg {
  display: none;
  color: #dc2626;
  font-size: 0.82rem;
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(220,38,38,0.07);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: var(--radius-sm);
}
.error-msg.visible { display: block; }

/* ── Content Sections ── */
.content-section {
  margin-top: 1.5rem;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.content-section h2 {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.875rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid rgba(134,239,172,0.3);
}
.content-section p {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.8;
  margin-bottom: 0.625rem;
}
.content-section p:last-child { margin-bottom: 0; }
.formula-box {
  background: rgba(22,163,74,0.06);
  border: 1px solid rgba(22,163,74,0.15);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}
.formula-box .formula-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.375rem;
}
.howto-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 0.25rem;
}
.howto-list li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.6;
}
.howto-list li .step-num {
  background: linear-gradient(135deg, #9333ea, #7c3aed);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.faq-list { display: flex; flex-direction: column; gap: 0; margin-top: 0.25rem; }
.faq-item { border-bottom: 1px solid rgba(134,239,172,0.2); }
.faq-item:last-child { border-bottom: none; }
.faq-question {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.75rem 0;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.faq-question .faq-icon { font-size: 1.1rem; color: var(--accent); line-height: 1; flex-shrink: 0; transition: transform 0.2s; }
.faq-item.open .faq-icon { transform: rotate(45deg); }
.faq-answer {
  display: none;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.75;
  padding-bottom: 0.875rem;
}
.faq-item.open .faq-answer { display: block; }

/* ── Site Footer ── */
.site-footer {
  margin-top: auto;
  padding-top: 2rem;
  padding-bottom: 1.5rem;
  border-top: 1px solid rgba(134,239,172,0.35);
}
.footer-section { margin-bottom: 1.5rem; }
.footer-heading {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-sub);
  letter-spacing: 0.06em;
  margin-bottom: 0.625rem;
}
.footer-dl { display: flex; flex-direction: column; gap: 5px; }
.footer-dl-row { display: flex; gap: 10px; font-size: 0.75rem; }
.footer-dl dt { font-weight: 600; color: var(--text-sub); min-width: 5.5rem; flex-shrink: 0; }
.footer-dl dd { color: var(--text-muted); }
.footer-dl a { color: var(--accent); text-decoration: none; }
.footer-dl a:hover { color: var(--accent2); text-decoration: underline; }
.share-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.share-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(134,239,172,0.4);
  border-radius: 9999px;
  color: var(--text-sub);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Noto Sans JP', sans-serif;
}
.share-pill:hover { background: rgba(255,255,255,0.8); border-color: var(--accent3); color: var(--accent); }
.share-pill svg { width: 12px; height: 12px; flex-shrink: 0; }
.footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 0.5rem;
}
.footer-text a { color: var(--accent); }
.footer-updated { text-align: center; font-size: 0.63rem; color: var(--text-dim); margin-bottom: 4px; }
.footer-disclaimer { font-size: 0.70rem; color: var(--text-muted); background: rgba(0,0,0,0.04); border-radius: 6px; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; line-height: 1.5; }
.footer-copyright { text-align: center; padding-top: 0.75rem; font-size: 0.63rem; color: var(--text-dim); letter-spacing: 0.04em; }
.footer-links { font-size: 0.72rem; color: var(--text-muted); text-align: center; }
.footer-links a { color: var(--accent); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }

/* ── Portal Page ── */
.portal-hero {
  padding: 1.5rem 0 1rem;
  text-align: center;
}
.portal-hero-label {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  color: rgba(109,40,217,0.6);
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
}
.portal-hero-title {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: #14311e;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.portal-hero-title .hero-big { font-size: 2.6rem; }
.portal-hero-desc {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.7;
}
.portal-intro {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.7;
}
.portal-section-label {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 0.62rem;
  color: rgba(109,40,217,0.5);
  letter-spacing: 0.2em;
  text-align: center;
  margin-bottom: 0.75rem;
}
.portal-grid {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 2rem;
}
.portal-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  transition: all 0.2s;
}
.portal-card:hover {
  background: rgba(255,255,255,0.8);
  box-shadow: 0 6px 24px rgba(22,163,74,0.1);
  transform: translateX(3px);
}
.portal-card-num {
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(22,163,74,0.08);
  border: 1px solid rgba(22,163,74,0.15);
  border-radius: 6px;
  padding: 3px 7px;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}
.portal-card-body { flex: 1; }
.portal-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.portal-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.portal-card-arrow {
  font-size: 1rem;
  color: rgba(109,40,217,0.4);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.portal-card:hover .portal-card-arrow { transform: translateX(3px); color: var(--accent); }

/* ── Related Tools ── */
.related-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.related-tools a { font-size: 0.78rem; color: var(--accent); text-decoration: none; background: rgba(22,163,74,0.08); padding: 0.25rem 0.6rem; border-radius: 999px; transition: background 0.15s; }
.related-tools a:hover { background: rgba(22,163,74,0.18); }

/* ── Info Table ── */
.info-table { width:100%; border-collapse:collapse; font-size:0.8rem; margin:0.75rem 0; }
.info-table th,.info-table td { padding:6px 8px; border:1px solid rgba(134,239,172,0.3); text-align:left; }
.info-table th { background:rgba(22,163,74,0.08); font-weight:600; color:var(--text-sub); }
.info-table td { color:var(--text-muted); }

/* ── Content ul ── */
.content-section ul { padding-left:1.2rem; margin:0.5rem 0; }
.content-section ul li { font-size:0.85rem; color:var(--text-sub); line-height:1.8; }

/* ── Stress / Radio ── */
.stress-question { margin-bottom:1rem; }
.stress-question p { font-size:0.85rem; font-weight:600; color:var(--text-sub); margin-bottom:0.4rem; }
.radio-group { display:flex; gap:0.5rem; flex-wrap:wrap; }
.radio-group label { display:flex; align-items:center; gap:4px; font-size:0.75rem; color:var(--text-muted); cursor:pointer; }
.radio-group input[type="radio"] { width:auto; min-height:auto; }
