/* 配色・書体は HMQ works の既存ツールに合わせる */
:root {
  --bg: #ffffff; --bg-soft: #f5f7f3; --accent: #789784; --link: #63836c;
  --text: #303a34; --muted: #66726a; --line: #e1e8e2; --on-link: #ffffff;
  --note: #7a5a1e; --note-bg: #fbf5e6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b211d; --bg-soft: #222a25; --accent: #8fb09b; --link: #9cc3a8;
    --text: #e4ebe6; --muted: #a3b1a8; --line: #36423a; --on-link: #1b211d;
    --note: #e9cd8f; --note-bg: #34301e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.7;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
}
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
main { max-width: 600px; margin: 0 auto; padding: 20px 16px 36px; }
h1 { font-size: 1.45rem; line-height: 1.4; margin: 0 0 2px; letter-spacing: .02em; }
.lead { margin: 0 0 14px; color: var(--muted); font-size: .88rem; line-height: 1.6; }
h2 { margin: 30px 0 12px; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
h2::before { content: ""; width: 18px; height: 3px; background: var(--accent); border-radius: 2px; flex: none; }
[hidden] { display: none !important; }

.card { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-h { margin: 0 0 4px; font-size: .95rem; }
.card-head .card-h { margin-bottom: 0; }

.row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.row-label { flex: none; width: 2.6em; font-weight: 700; font-size: .9rem; color: var(--muted); }
.fields { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 4px; min-width: 0; }
.u { font-size: .95rem; color: var(--muted); margin-right: 4px; }

input[type="text"], select {
  font: inherit; font-size: 1.3rem; font-weight: 700; line-height: 1.3;
  padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-variant-numeric: tabular-nums;
  text-align: center; min-width: 0;
}
.n4 { width: 4.4em; }
.n2 { width: 2.9em; }
select { text-align: left; padding: 5px 4px; width: auto; }
input::placeholder { color: var(--muted); font-weight: 400; opacity: .5; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(120, 151, 132, .25); }

.cal { position: relative; width: 38px; height: 38px; flex: none; margin-left: 2px; }
.cal svg { position: absolute; inset: 7px; width: 24px; height: 24px; fill: none; stroke: var(--link); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.cal input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; font-size: 16px; }
.cal:focus-within { outline: 2px solid var(--link); outline-offset: 1px; border-radius: 8px; }
.cal:hover { background: var(--line); border-radius: 8px; }

.leap { font-size: .9rem; margin-left: 6px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.leap input { width: 18px; height: 18px; accent-color: var(--link); }
.badge { font-size: .75rem; color: var(--note); background: var(--note-bg); border-radius: 99px; padding: 1px 10px; margin-left: 4px; }

.btn {
  font: inherit; font-size: .85rem; color: var(--link); background: var(--bg); cursor: pointer;
  border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px;
}
.btn:hover { border-color: var(--accent); }

.ref-w { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 0; font-weight: 700; }
.ref-w #ref-wareki { font-variant-numeric: tabular-nums; }

.note { margin: 8px 0 0; padding: 6px 12px; border-radius: 8px; background: var(--note-bg); color: var(--note); font-size: .88rem; line-height: 1.6; }

.result { text-align: center; padding: 10px 14px 12px; }
.result .card-h { justify-content: center; }
.age { margin: 0; font-size: 2.1rem; font-weight: 700; line-height: 1.4; color: var(--text); font-variant-numeric: tabular-nums; }
.age.empty { font-size: 1.05rem; font-weight: 400; color: var(--muted); }
.age.warn { font-size: 1.05rem; font-weight: 400; color: var(--note); }
.days { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--link); font-variant-numeric: tabular-nums; min-height: 1.6em; }
.detail { margin: 2px 0 0; font-size: .85rem; color: var(--muted); min-height: 1.4em; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
thead th { background: var(--link); color: var(--on-link); padding: 7px; font-size: .9rem; }
tbody th, td { padding: 6px 10px; font-size: .95rem; border-top: 1px solid var(--line); text-align: left; }
tbody th { width: 4.5em; font-weight: 700; }
tbody tr:nth-child(odd) th, tbody tr:nth-child(odd) td { background: var(--bg-soft); }
sup { font-size: .7em; }
.small { font-size: .8rem; color: var(--muted); margin: 6px 0 0; line-height: 1.6; }

.notes details { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; padding: 0 12px; }
.notes summary { cursor: pointer; padding: 8px 0; font-size: .92rem; font-weight: 700; }
.notes ul { margin: 0 0 10px; padding-left: 1.2em; font-size: .86rem; line-height: 1.7; color: var(--muted); }
.notes li { margin-bottom: 4px; }

footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); text-align: center; font-size: .85rem; color: var(--muted); }
footer a { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.noscript { text-align: center; color: var(--note); }

@media (max-width: 480px) {
  main { padding: 14px 12px 30px; }
  h1 { font-size: 1.3rem; }
  .lead { margin-bottom: 10px; }
  .card { padding: 10px 10px; }
  .row { gap: 6px; }
  .row-label { width: 2.2em; font-size: .8rem; }
  .fields { gap: 3px 2px; }
  input[type="text"], select { font-size: 1.1rem; padding: 4px 3px; }
  .n4 { width: 3.5em; }
  .n2 { width: 2.3em; }
  .u { font-size: .8rem; margin-right: 2px; }
  .cal { width: 34px; height: 34px; margin-left: 0; }
  .cal svg { inset: 5px; }
  .age { font-size: 1.9rem; }
}
@media (max-width: 360px) {
  .row { flex-direction: column; align-items: flex-start; gap: 0; }
  .row-label { width: auto; }
}
