:root {
  --bg: #f7f3ea; --surface: #fffdf8; --ink: #2b2622; --muted: #7a7068; --line: #e4dccd;
  --accent: #c8442c; --accent-ink: #fff; --me: #fbeee6; --warn-bg: #fff4d6; --warn-ink: #7a5600;
  --wood: #3f7d4e; --fire: #c8442c; --earth: #a07a2c; --metal: #6b6f78; --water: #2e5f9a;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .06);
  --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: #1b1917; --surface: #252220; --ink: #ece6dd; --muted: #a39a90; --line: #3a3531;
    --accent: #e0664d; --me: #3a2721; --warn-bg: #3b3118; --warn-ink: #f0d189;
    --wood: #7cc08c; --fire: #ef7a62; --earth: #d8b061; --metal: #b4b8c0; --water: #7fa9e0;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1917; --surface: #252220; --ink: #ece6dd; --muted: #a39a90; --line: #3a3531;
  --accent: #e0664d; --me: #3a2721; --warn-bg: #3b3118; --warn-ink: #f0d189;
  --wood: #7cc08c; --fire: #ef7a62; --earth: #d8b061; --metal: #b4b8c0; --water: #7fa9e0;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.7 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* 上のバー */
.bar-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  height: 56px; padding: 0 8px; padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-top h1 { flex: 1; margin: 0 8px; font: 600 18px/1 var(--serif); letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--ink); font-size: 28px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--line); }
.icon-btn[hidden] { display: none; }

/* 共通部品 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); }
.h { font: 600 16px/1.4 var(--serif); margin: 0 0 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: 15px; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--accent); }
.btn.wide { width: 100%; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 12px; }
.actions.sub { display: flex; flex-wrap: wrap; gap: 8px; }
.notice { background: var(--me); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.term {
  border: 0; padding: 0; margin: 0; background: none; color: inherit; font: inherit; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 4px; text-decoration-color: var(--accent);
}
.term:hover { color: var(--accent); }
.seal { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: var(--accent); color: #fff; font: 700 22px/1 var(--serif); }
.seal.big { width: 72px; height: 72px; font-size: 40px; border-radius: 14px; transform: rotate(-4deg); }

/* ホーム */
.empty { text-align: center; padding: 48px 8px; }
.empty h2 { font: 600 22px/1.5 var(--serif); margin: 20px 0 8px; }
.list-head { margin: 0 4px 8px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.person { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.person:hover { border-color: var(--accent); }
.person-day { font: 600 22px/1 var(--serif); writing-mode: vertical-rl; letter-spacing: .1em; color: var(--accent); padding: 4px 0; }
.person-main { flex: 1; display: grid; min-width: 0; }
.person-main strong { font-size: 17px; }
.chev { color: var(--muted); font-size: 24px; }

.main-cta { display: flex; justify-content: center; margin: 20px 0 22px; }
.btn.cta { min-height: 60px; min-width: min(100%, 320px); padding: 0 32px; font-size: 19px; border-radius: 16px; box-shadow: 0 6px 18px rgba(200, 68, 44, .3); }
.empty .main-cta { margin: 24px 0 18px; }
.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20; height: 56px; padding: 0 22px; border: 0; border-radius: 18px;
  background: var(--accent); color: #fff; font: 600 16px/1 inherit; font-family: inherit;
  box-shadow: 0 6px 18px rgba(200, 68, 44, .35); cursor: pointer;
}
.fab[hidden] { display: none; }

/* 入力 */
.form label { display: grid; gap: 4px; margin-bottom: 16px; font-weight: 600; font-size: 15px; }
.form input:not([type="checkbox"]):not([type="radio"]), .form select {
  font: inherit; font-weight: 400; min-height: 46px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink); width: 100%;
}
.form input:disabled { opacity: .45; }
.form .row { display: flex; gap: 12px; align-items: end; }
.form .grow { flex: 1; }
.form .check { display: flex; align-items: center; gap: 6px; font-weight: 400; min-height: 46px; white-space: nowrap; }
.form fieldset { border: 0; padding: 0; margin: 0 0 16px; }
.form legend { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.radio { display: inline-flex !important; align-items: center; gap: 6px; margin-right: 18px; font-weight: 400 !important; cursor: pointer; }
.radio.block { display: flex !important; align-items: flex-start; margin: 0 0 10px; }
.radio.block input { margin-top: 6px; }
input[type="radio"], input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.req { font-size: 11px; font-weight: 600; color: var(--accent); margin-left: 8px; }
.hint { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.hint.inline { display: inline; }
.err { color: var(--accent); min-height: 1.5em; margin: 0 0 8px; font-size: 14px; }

/* 命式表 */
.table-wrap { overflow-x: auto; }
.chart { width: 100%; border-collapse: collapse; text-align: center; table-layout: fixed; }
.chart th, .chart td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.chart thead th { font: 600 14px/1 var(--serif); color: var(--muted); }
.chart tbody th { font-size: 12px; font-weight: 400; color: var(--muted); text-align: left; width: 22%; }
.chart .me { background: var(--me); }
.chart thead th.me { color: var(--accent); }
.kan { font: 600 34px/1.1 var(--serif); }
.kan.sm { font-size: 20px; }
.wood { color: var(--wood); } .fire { color: var(--fire); } .earth { color: var(--earth); } .metal { color: var(--metal); } .water { color: var(--water); }
.bars { display: grid; gap: 6px; margin-bottom: 10px; }
.bar { display: grid; grid-template-columns: 28px 1fr 24px; align-items: center; gap: 8px; }
.bar-l { font: 600 16px/1 var(--serif); }
.bar-t { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-f { display: block; height: 100%; border-radius: 99px; background: currentColor; }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: flex; gap: 12px; align-items: baseline; margin: 0; }
.kv strong { font: 600 18px/1 var(--serif); }

/* 根拠 */
.steps { list-style: none; padding: 0; margin: 0; }
.step-h { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.step-h h2 { flex: 1; margin: 0; font: 600 17px/1.3 var(--serif); }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.step-r { font: 600 24px/1 var(--serif); color: var(--accent); }
.step ul, .plain { margin: 0; padding-left: 1.2em; }
.step li, .plain li { margin: 4px 0; }

/* 大運 */
.lead { font: 600 20px/1.4 var(--serif); margin: 0 0 8px; }
.daiun { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.daiun th, .daiun td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.daiun th { font-size: 12px; color: var(--muted); font-weight: 400; }
.daiun tr.now { background: var(--me); }
.badge { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--accent); color: #fff; }

/* 設定 */
.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; cursor: pointer; }
.prose p { margin: 0 0 14px; }

/* 広告（PR表示は消費者庁Q&Aに沿って、本文と同じくらい読める大きさ・はっきりした色にする） */
.pr { display: inline-block; margin-right: 8px; padding: 1px 7px; border: 1.5px solid var(--ink); border-radius: 4px; font-size: 13px; font-weight: 700; line-height: 1.4; color: var(--ink); vertical-align: 1px; }
.ads { border-style: dashed; }
.ads-h { display: flex; align-items: center; }
.ad-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ad > a { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: inherit; text-decoration: none; }
.ad > a:hover { border-color: var(--accent); }
.ad-img { width: 64px; height: 64px; object-fit: contain; flex: none; }
.ad-body { flex: 1; display: grid; gap: 2px; min-width: 0; }
.ad-body .pr { justify-self: start; }
.ad-go { color: var(--muted); }
.ad-pixel { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ads-note { margin: 10px 0 0; font-size: 13px; color: var(--ink); }

/* フッター */
.foot { text-align: center; padding-top: 8px; padding-bottom: 24px; border-top: 1px solid var(--line); margin-top: 12px; }
.foot-pr { font-size: 14px; margin: 8px 0; }
.foot-nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0; font-size: 14px; }
.foot p { margin: 4px 0; }

/* 意見箱 */
.warn-inline { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 8px 12px; }
.form-frame { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 10px; }
.form-frame::before { content: "フォームを読み込んでいます…"; position: absolute; top: 40px; left: 0; right: 0; text-align: center; color: #7a7068; font-size: 14px; }
.form-frame iframe { position: relative; display: block; width: 100%; height: 860px; border: 0; }

/* 解説シート */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; background: var(--surface); color: var(--ink); }
.sheet::backdrop { background: rgba(0, 0, 0, .35); }
.sheet-in { padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { font: 600 22px/1.3 var(--serif); margin: 0 0 8px; color: var(--accent); }
.sheet p { margin: 0 0 18px; }
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 18px; } }

.toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }

@media (max-width: 420px) {
  .daiun { font-size: 12.5px; } .daiun th, .daiun td { padding: 8px 3px; } .kan.sm { font-size: 17px; }
  .card { padding: 14px 12px; }
}
@media (max-width: 380px) { .kan { font-size: 28px; } .chart tbody th { font-size: 11px; } }
