/* ManyCal — shared styles */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2dd;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7c7b76;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e6f0fc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #e8e7e2;
  --critical: #c93b3a;
  --critical-soft: #fdecec;
  --good: #16865e;
  --good-soft: #e5f5ee;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #2f2f2c;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #93928a;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #1b2a3d;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --grid: #2c2c29;
    --critical: #e66767;
    --critical-soft: #3a1f1f;
    --good: #3cc28f;
    --good-soft: #17302a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #242422;
  --border: #2f2f2c;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #93928a;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-soft: #1b2a3d;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --grid: #2c2c29;
  --critical: #e66767;
  --critical-soft: #3a1f1f;
  --good: #3cc28f;
  --good-soft: #17302a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "palt";
}
a { color: var(--accent-ink); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1160px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; height: 56px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; letter-spacing: .01em;
  color: var(--text); text-decoration: none; flex: none;
}
.logo svg { width: 26px; height: 26px; }
.nav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin-left: auto;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; padding: 6px 12px; border-radius: 999px;
  color: var(--text-2); text-decoration: none; font-size: 14px; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
@media (max-width: 640px) {
  .site-header .inner { flex-direction: column; align-items: stretch; height: auto; gap: 0; padding-top: 8px; }
  .nav { margin: 4px -16px 0; padding: 0 12px 8px; }
}

/* ---------- layout ---------- */
main { max-width: 1160px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { margin: 8px 0 20px; }
.page-head h1 { font-size: clamp(22px, 3.2vw, 30px); margin: 0 0 4px; letter-spacing: .01em; }
.page-head p { margin: 0; color: var(--text-2); }

.calc {
  display: grid; gap: 20px;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 860px) { .calc { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card h2 { font-size: 16px; margin: 0 0 14px; }
.card + .card { margin-top: 20px; }
.tools > .card + .card { margin-top: 0; } /* grid items: spacing comes from gap */
@media (min-width: 861px) { .calc > form.card { position: sticky; top: 76px; } }

/* ---------- form ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
legend {
  font-size: 12px; font-weight: 700; color: var(--text-3);
  letter-spacing: .08em; padding: 0; margin-bottom: 8px;
}
fieldset + fieldset { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 8px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.field .opt { font-weight: 400; color: var(--text-3); font-size: 12px; margin-left: 4px; }
.input-wrap {
  display: flex; align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input-wrap input, .input-wrap select {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; padding: 9px 12px; outline: none;
  font-variant-numeric: tabular-nums;
}
.input-wrap select { appearance: none; cursor: pointer; padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.input-wrap .unit { padding: 0 12px 0 0; color: var(--text-3); font-size: 13px; white-space: nowrap; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 3px; min-height: 1em; }
.row2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.seg label { flex: 1; margin: 0; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 6px 4px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.seg input:checked + span { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.actions { display: flex; gap: 8px; margin-top: 6px; }
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; flex: 1; font-size: 15px; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn svg { width: 16px; height: 16px; }

/* ---------- results ---------- */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.result-head h2 { margin: 0; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; min-width: 0;
}
.kpi .label { font-size: 12.5px; color: var(--text-2); }
.kpi .value { font-size: clamp(20px, 2.6vw, 26px); font-weight: 700; letter-spacing: -.01em; line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .sub { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.kpi.long .value { font-size: clamp(18px, 2vw, 22px); }
.kpi.hero { grid-column: 1 / -1; background: var(--accent-soft); border-color: transparent; }
.kpi.hero .value { font-size: clamp(30px, 5vw, 42px); color: var(--accent-ink); }
.kpi .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.notice { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin: 14px 0 0; display: flex; gap: 8px; align-items: flex-start; }
.notice svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.notice.warn { background: var(--critical-soft); color: var(--critical); }
.notice.ok { background: var(--good-soft); color: var(--good); }
.notice.info { background: var(--surface-2); color: var(--text-2); }

/* ---------- chart ---------- */
.chart-title { font-size: 14px; font-weight: 650; margin: 0 0 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; }
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); }
.chart .axis-base { stroke: var(--text-3); stroke-opacity: .5; }
.chart .plot { clip-path: inset(0 100% 0 0); }
.chart.drawn .plot { clip-path: inset(0 0 0 0); transition: clip-path .9s cubic-bezier(.3,.7,.2,1); }
.chart.static .plot { clip-path: none; transition: none; }
.chart .marker line { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart .marker text { fill: var(--text-2); font-size: 11px; }
.chart .hline line { stroke: var(--text); stroke-dasharray: 5 4; stroke-width: 1.5; }
.chart .hline text { fill: var(--text); font-weight: 600; }
.chart .guide { stroke: var(--text-2); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar-hover { fill: var(--text); fill-opacity: .06; pointer-events: none; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  padding: 8px 10px; font-size: 12.5px; line-height: 1.5; min-width: 150px;
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
  white-space: nowrap;
}
.tooltip.show { opacity: 1; transform: none; }
.tooltip .t { font-weight: 700; margin-bottom: 2px; }
.tooltip .r { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tooltip .r span:first-child { color: var(--text-2); }
.tooltip .r i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.tooltip .r.total { border-top: 1px solid var(--border); margin-top: 3px; padding-top: 3px; font-weight: 650; }

/* ---------- table ---------- */
details.table-wrap { margin-top: 0; }
details.table-wrap summary {
  cursor: pointer; font-weight: 650; font-size: 14px; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details.table-wrap summary::-webkit-details-marker { display: none; }
details.table-wrap summary::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2);
  transform: rotate(-45deg); transition: transform .15s; margin-right: 2px;
}
details.table-wrap[open] summary::before { transform: rotate(45deg); }
.scroll-x { overflow-x: auto; margin-top: 12px; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.data th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
table.data th:first-child, table.data td:first-child { text-align: left; }
/* 項目名は折り返して、金額の列が画面からはみ出さないようにする */
table.data td:first-child { white-space: normal; min-width: 7em; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tr.phase td { background: var(--surface-2); color: var(--text-2); font-size: 12px; text-align: left; font-weight: 600; }
table.data tr.hl td { background: var(--accent-soft); }

/* ---------- home ---------- */
section.hero {
  padding: 36px 0 28px; text-align: left;
}
section.hero h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.2; margin: 0 0 10px; letter-spacing: -.01em; }
section.hero h1 em { font-style: normal; color: var(--accent-ink); }
section.hero p { color: var(--text-2); font-size: 16px; margin: 0; max-width: 40em; }
.tools { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 8px; }
.tool {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.tool .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 12px; }
.tool .ico svg { width: 24px; height: 24px; }
.tool h2 { margin: 0 0 4px; font-size: 18px; }
.tool p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; flex: 1; }
.tool .go { font-size: 13.5px; font-weight: 650; color: var(--accent-ink); }
.presets { margin-top: 36px; }
.presets h2 { font-size: 18px; margin: 0 0 12px; }
.preset-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.preset-list a {
  display: block; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); font-size: 14px;
}
.preset-list a:hover { border-color: var(--accent); }
.preset-list a small { display: block; color: var(--text-3); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.site-footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 24px 16px 40px; border-top: 1px solid var(--border); }
.site-footer p { margin: 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .chart .plot, .chart.drawn .plot { clip-path: none; transition: none; }
  * { transition: none !important; }
}
@media print {
  .site-header, form.card, .actions, .site-footer { display: none; }
  .calc { grid-template-columns: 1fr; }
}
#result { scroll-margin-top: 100px; min-width: 0; }

/* ---------- breakdown bar (100% stacked) ---------- */
.breakdown { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface); margin: 6px 0 10px; }
.breakdown span { display: block; min-width: 2px; }
.checkrow { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkrow input { width: 18px; height: 18px; accent-color: var(--accent); }
table.data td.strong { font-weight: 700; }
table.data tr.sum td { font-weight: 700; border-top: 2px solid var(--border); }
.card > h2 + .scroll-x { margin-top: 0; }
.note { font-size: 12.5px; color: var(--text-3); margin: 12px 0 0; }
.foot-links { line-height: 2; }
.foot-links a { color: var(--text-2); text-decoration: none; }
.foot-links a:hover { color: var(--accent-ink); text-decoration: underline; }
.chart .band { fill: var(--critical); fill-opacity: .1; }
.legend i.band { background: var(--critical) !important; opacity: .25; }
/* ---------- FAQ ---------- */
.faq-list { margin-top: 24px; }
.faq-list h2 { margin-bottom: 6px; }
details.faq { border-top: 1px solid var(--border); padding: 12px 0; }
details.faq:first-of-type { border-top: 0; }
details.faq summary { cursor: pointer; font-weight: 650; font-size: 14.5px; list-style: none; display: flex; gap: 10px; align-items: baseline; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before { content: "Q"; color: var(--accent-ink); font-weight: 800; flex: none; }
details.faq p { margin: 8px 0 0 22px; color: var(--text-2); font-size: 14px; }
table.data.text th:nth-child(2), table.data.text td:nth-child(2) { text-align: left; white-space: normal; min-width: 8em; }

/* 免責事項・プライバシーポリシー */
.legal { max-width: 820px; }
.legal .card p { margin: 0 0 10px; line-height: 1.8; }
.legal .card p:last-child { margin-bottom: 0; }
.legal-date { color: var(--text-3); font-size: 13px; text-align: right; margin: 20px 0 0; }
.copyright { margin-top: 8px; }
