/* 筆算舎の早見帳（Hissansha） 共通スタイル（外部フォント・外部ファイルは読み込まない） */

:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #f0ebe0;
  --ink: #1f2124;
  --ink-2: #4a4d52;
  --muted: #6b6e73;
  --line: #ddd5c5;
  --line-strong: #c9bea9;
  --accent: #1f4e79;       /* 藍 */
  --accent-soft: #e3ecf4;
  --shu: #b23a26;          /* 朱 */
  --shu-soft: #f8e6e1;
  --gold: #8a6a1f;
  --gold-soft: #f4ecd6;
  --sun: #b23a26;
  --sat: #1f5d99;
  --focus: #2a6fb0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 14px rgba(60, 45, 20, .05);
  --font-sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #25292e;
    --ink: #ebe7df;
    --ink-2: #c9c5bd;
    --muted: #9b9a96;
    --line: #34383e;
    --line-strong: #474c53;
    --accent: #8fbbe0;
    --accent-soft: #1d2e3f;
    --shu: #ec8d78;
    --shu-soft: #3b231e;
    --gold: #d8b866;
    --gold-soft: #332a17;
    --sun: #ec8d78;
    --sat: #8fbbe0;
    --focus: #8fbbe0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1d2024; --surface-2: #25292e; --ink: #ebe7df; --ink-2: #c9c5bd; --muted: #9b9a96;
  --line: #34383e; --line-strong: #474c53; --accent: #8fbbe0; --accent-soft: #1d2e3f; --shu: #ec8d78; --shu-soft: #3b231e;
  --gold: #d8b866; --gold-soft: #332a17; --sun: #ec8d78; --sat: #8fbbe0; --focus: #8fbbe0; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: .02em;
  font-feature-settings: "palt" 0;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* ---------- ヘッダー ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; padding-top: 12px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; letter-spacing: .12em; }
.brand-sub { display: block; font-size: .72rem; color: var(--muted); letter-spacing: .06em; line-height: 1.3; font-family: var(--font-sans); font-weight: 400; }

.tool-nav { border-top: 1px solid var(--line); background: var(--surface); }
.tool-nav ul {
  list-style: none; margin: 0 auto; padding: 8px 16px; max-width: 760px;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.tool-nav ul::-webkit-scrollbar { display: none; }
.tool-nav a {
  display: block; white-space: nowrap; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: .88rem; line-height: 1.5;
  background: var(--bg);
}
.tool-nav a:hover { border-color: var(--line-strong); color: var(--ink); }
.tool-nav a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }

/* ---------- 本文 ---------- */
main { padding: 20px 0 48px; }

.breadcrumb { font-size: .8rem; color: var(--muted); margin: 0 0 10px; }
.breadcrumb a { color: var(--muted); }

h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem; line-height: 1.45; margin: 0 0 10px; letter-spacing: .04em; font-weight: 600;
}
h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem; line-height: 1.5; margin: 40px 0 12px; padding-bottom: 6px; font-weight: 600;
  border-bottom: 2px solid var(--line);
  position: relative;
}
h2::after { content: ""; position: absolute; left: 0; bottom: -2px; width: 56px; height: 2px; background: var(--shu); }
h3 { font-size: 1.05rem; margin: 24px 0 8px; }
.lead { color: var(--ink-2); margin: 0 0 18px; }
p { margin: 0 0 14px; }
ul.plain, ol.plain { padding-left: 1.3em; margin: 0 0 14px; }
ul.plain li, ol.plain li { margin-bottom: 6px; }
.small { font-size: .85rem; color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- 計算ツールの枠 ---------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
  margin: 0 0 8px;
}
.tool + .tool { margin-top: 16px; }
.tool-title { font-size: .95rem; font-weight: 700; margin: 0 0 12px; color: var(--ink-2); letter-spacing: .06em; }

.fields { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field.grow { flex: 1 1 180px; }
.field.date { flex: 1 1 150px; }
.field select, .field input[type="date"] { width: 100%; }
.fields.date3 { display: grid; grid-template-columns: 1fr 1fr; }
.fields.date3 .field:first-child { grid-column: 1 / -1; }
@media (min-width: 560px) {
  .fields.date3 { grid-template-columns: 1fr 7.5em 7.5em; }
  .fields.date3 .field:first-child { grid-column: auto; }
}

select, input[type="date"], input[type="number"] {
  font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  min-height: 46px;
  padding: 8px 10px;
  max-width: 100%;
}
select { padding-right: 30px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type="number"] { width: 6.5em; }
input[type="date"] { min-width: 0; }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: .92rem; margin-top: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }

.btn {
  font: inherit; font-size: .9rem; cursor: pointer;
  min-height: 40px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.result {
  margin-top: 16px; padding: 14px 14px 6px;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
}
.result[hidden] { display: none; }
.result-main { font-size: 1.05rem; margin: 0 0 10px; }
.result-big { font-family: var(--font-serif); font-size: 2rem; font-weight: 600; line-height: 1.2; color: var(--accent); letter-spacing: .02em; }
.result-big small { font-size: 1rem; color: var(--ink-2); font-family: var(--font-sans); font-weight: 400; margin-left: 2px; }
.result dl { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0 0 10px; }
.result dt { color: var(--muted); font-size: .82rem; margin-top: 10px; }
.result dt:first-child { margin-top: 0; }
.result dd { margin: 0; font-weight: 600; }
@media (min-width: 560px) {
  .result dl { grid-template-columns: 11em 1fr; gap: 8px 14px; }
  .result dt { margin-top: 0; padding-top: 2px; font-size: .88rem; }
}
.result .note { font-size: .85rem; color: var(--ink-2); margin: 8px 0 10px; }
.error { color: var(--shu); font-weight: 600; }

.privacy-note {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: .8rem; color: var(--muted); margin: 10px 0 0; line-height: 1.6;
}
.privacy-note svg { flex: none; width: 16px; height: 16px; margin-top: 2px; }

/* 厄年・六曜の印 */
.tag {
  display: inline-block; font-size: .8rem; font-weight: 700; line-height: 1.4;
  padding: 2px 8px; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap;
}
.tag.honyaku { color: var(--shu); background: var(--shu-soft); }
.tag.zenyaku, .tag.koyaku { color: var(--gold); background: var(--gold-soft); }
.tag.none { color: var(--muted); }
.tag.taiyaku { color: var(--surface); background: var(--shu); border-color: var(--shu); }

/* ---------- 表 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 12px; }
table.hayami { width: 100%; border-collapse: collapse; font-size: .92rem; line-height: 1.5; }
table.hayami caption { text-align: left; font-size: .82rem; color: var(--muted); padding: 8px 12px; caption-side: bottom; }
table.hayami th, table.hayami td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.hayami thead th { background: var(--surface-2); font-size: .8rem; color: var(--ink-2); position: sticky; top: 0; }
table.hayami tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.hayami tbody tr:last-child th, table.hayami tbody tr:last-child td { border-bottom: 0; }
table.hayami tbody th { font-weight: 600; }
table.hayami td.num, table.hayami th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.hayami tr.is-hl { background: var(--accent-soft) !important; }
.table-scroll { max-height: 70vh; overflow-y: auto; }

details.era { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 10px; }
details.era > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.era > summary::-webkit-details-marker { display: none; }
details.era > summary::after { content: "＋"; color: var(--muted); font-weight: 400; }
details.era[open] > summary::after { content: "－"; }
details.era > summary .small { font-weight: 400; }
details.era .table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); margin: 0; }

/* ---------- 説明の箱 ---------- */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.box > :last-child { margin-bottom: 0; }
.box.method { border-left: 4px solid var(--accent); }
.box.caution { border-left: 4px solid var(--gold); }
.box h3 { margin-top: 0; }
.sources { font-size: .88rem; }
.sources li { word-break: break-word; }

/* ---------- トップページ ---------- */
.hero { padding: 6px 0 4px; }
.hero h1 { font-size: 1.7rem; }
.tool-cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.tool-card a {
  display: grid; grid-template-columns: 52px 1fr; gap: 4px 14px; align-items: start;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none;
}
.tool-card a:hover { border-color: var(--accent); }
.tool-card .ico {
  grid-row: span 2; width: 52px; height: 52px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-family: var(--font-serif); font-size: 1.35rem; font-weight: 700;
}
.tool-card:nth-child(2) .ico, .tool-card:nth-child(5) .ico { background: var(--shu-soft); color: var(--shu); }
.tool-card .t { font-weight: 700; font-size: 1.05rem; line-height: 1.5; }
.tool-card .d { color: var(--ink-2); font-size: .9rem; line-height: 1.6; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 12px; }
.facts div { background: var(--surface); padding: 12px 14px; }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-size: 1.02rem; line-height: 1.5; }
.facts dd span { font-weight: 400; font-size: .85rem; color: var(--ink-2); }

/* ---------- 六曜カレンダー ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.cal-head h3 { margin: 0; font-family: var(--font-serif); font-size: 1.3rem; }
.cal-head .btn { min-width: 44px; }
.cal { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.cal th { font-size: .78rem; color: var(--muted); font-weight: 600; padding: 2px 0 4px; text-align: center; }
.cal th:first-child { color: var(--sun); }
.cal th:last-child { color: var(--sat); }
.cal td { vertical-align: top; padding: 0; }
.cal .day {
  min-height: 64px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line);
  padding: 4px 4px 5px; display: flex; flex-direction: column; gap: 1px; line-height: 1.25;
}
.cal .day.empty { background: transparent; border-color: transparent; }
.cal .dnum { font-weight: 700; font-size: .98rem; font-variant-numeric: tabular-nums; }
.cal .sun .dnum, .cal .hol .dnum { color: var(--sun); }
.cal .sat .dnum { color: var(--sat); }
.cal .rk { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.cal .kyu { font-size: .64rem; color: var(--muted); white-space: nowrap; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.cal .hname { font-size: .6rem; color: var(--sun); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .day.r-大安 { background: var(--shu-soft); border-color: color-mix(in srgb, var(--shu) 35%, transparent); }
.cal .day.r-大安 .rk { color: var(--shu); }
.cal .day.r-仏滅 .rk { color: var(--muted); }
.cal .day.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal .day.dim { opacity: .35; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin: 8px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.chip { font: inherit; font-size: .85rem; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.month-list { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.month-list li { display: grid; grid-template-columns: 4.2em 1fr; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.month-list li:last-child { border-bottom: 0; }
.month-list .m { font-weight: 700; font-family: var(--font-serif); }
.month-list .ds { display: flex; flex-wrap: wrap; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.month-list .ds span { white-space: nowrap; }
.month-list .ds .we { color: var(--sun); font-weight: 600; }

/* ---------- フッター ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 24px 0 32px; font-size: .88rem; color: var(--ink-2); }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.site-footer a { color: var(--ink-2); }
.site-footer .privacy { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; font-size: .82rem; line-height: 1.7; }
.site-footer .copy { font-size: .78rem; color: var(--muted); margin: 0; }

@media (min-width: 640px) {
  h1 { font-size: 1.9rem; }
  .hero h1 { font-size: 2rem; }
  .tool { padding: 22px 22px 18px; }
  .tool-cards { grid-template-columns: 1fr 1fr; }
  .tool-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cal .day { min-height: 76px; padding: 6px 6px 6px; }
  .cal .rk { font-size: .85rem; }
  .cal .kyu { font-size: .7rem; }
  .cal .hname { font-size: .68rem; }
}

@media (max-width: 380px) {
  .cal { border-spacing: 1px; }
  .cal .day { padding: 3px 2px; min-height: 58px; }
  .cal .rk { font-size: .72rem; letter-spacing: 0; }
  .cal .kyu { font-size: .58rem; letter-spacing: 0; }
}

@media print {
  .site-header, .tool-nav, .site-footer, .tool .btn-row { display: none; }
  body { background: #fff; }
}

/* サイトの印（暦の紙と月） */
.brand-mark .bm-body { fill: #1f4e79; }
.brand-mark .bm-top { fill: #b23a26; }
.brand-mark .bm-ring { fill: var(--ink); }
.brand-mark .bm-moon { fill: #f3e3b3; }
