/* こよみさんぽ：マットで親しみやすい見た目。スマホ（幅360px〜）基準、PCは最大幅480pxで中央寄せ */

:root {
  --bg: #F5EFE3;          /* 生成り */
  --ink: #3B342C;         /* 茶寄りの黒（背景とのコントラスト 10.7:1） */
  --muted: #6E655A;       /* 補足の文字（背景とのコントラスト 5.0:1） */
  --card: #FFFDF8;
  --line: #E2D9C8;
  --soft: #EFE7D7;

  /* くすんだ4色（目安の色。図形用） */
  --red: #C4665A;
  --white: #E9E3D6;
  --blue: #6C8FA8;
  --yellow: #D9B25F;
  --green: #7E9A73;

  /* 数字を重ねる丸の色（白文字・茶文字とのコントラスト 4.5:1 以上に調整） */
  --red-ink: #B0564B;     /* 白文字 4.9:1 */
  --blue-ink: #4F7590;    /* 白文字 4.9:1 */
  --white-edge: #8C8172;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(59, 52, 44, 0.06);
  --tabbar-h: 60px;
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

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

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

body {
  margin: 0 auto;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
}

a { color: var(--ink); text-underline-offset: 3px; }

h1, h2, h3, p { margin: 0; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--card); padding: 8px 12px; border-radius: 8px;
}
.skip:focus { left: 8px; top: 8px; z-index: 100; }

:focus-visible { outline: 3px solid var(--blue-ink); outline-offset: 2px; }

/* ---------- ヘッダー・フッター ---------- */

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px 6px;
}
.brand { text-decoration: none; display: flex; flex-direction: column; line-height: 1.3; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: 0.06em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.header-link {
  font-size: 14px; color: var(--muted); white-space: nowrap;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px;
}

.site-footer {
  padding: 20px 16px 24px; color: var(--muted); font-size: 13px; text-align: center;
  display: grid; gap: 6px;
}
.site-footer a { color: var(--muted); display: inline-block; padding: 6px 4px; }
.footer-links { display: flex; justify-content: center; align-items: center; gap: 4px; }

/* ---------- 本文 ---------- */

.view { display: grid; gap: 14px; padding: 8px 12px 0; outline: none; }
.view-title { font-size: 22px; letter-spacing: 0.04em; padding: 4px 4px 0; }
.view-title:focus { outline: none; }
.section-title { font-size: 18px; padding: 10px 4px 0; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid; gap: 10px;
}

.sub { font-size: 17px; }
.small { font-size: 13px; color: var(--muted); line-height: 1.6; }
.block { display: block; }
.note {
  font-size: 13px; color: var(--ink); background: var(--soft);
  border-radius: 10px; padding: 8px 10px; line-height: 1.6;
}
.privacy-note {
  font-size: 13px; color: var(--ink); background: var(--soft);
  border-radius: 10px; padding: 8px 10px; line-height: 1.6;
}
.eyebrow { font-size: 13px; color: var(--muted); letter-spacing: 0.08em; }
.prose { gap: 8px; }
.prose .sub { margin-top: 8px; }
.prose .sub:first-child { margin-top: 0; }

/* ---------- KINカード ---------- */

.kin-card .date { font-size: 15px; color: var(--muted); }
.kin-head { display: flex; align-items: center; gap: 14px; }
.kin-no { font-size: 14px; color: var(--muted); letter-spacing: 0.06em; }
.glyph-name { font-size: 24px; line-height: 1.35; }
.meta { font-size: 14px; color: var(--muted); }

.hitokoto {
  background: var(--soft); border-radius: 12px; padding: 12px 14px; line-height: 1.85;
}

.facts { margin: 0; display: grid; gap: 6px; }
.facts > div { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.tag-black, .black-inline {
  display: inline-flex; align-items: center; gap: 4px; justify-self: start;
  background: var(--ink); color: var(--card);
  font-size: 13px; font-weight: 700; border-radius: 999px; padding: 2px 12px;
}
.black-inline { padding: 0 8px; font-size: 12px; }

/* 紋章の丸（色＋番号） */
.badge {
  flex: none;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  font-weight: 700; font-size: 16px; line-height: 1;
}
.badge.lg { width: 64px; height: 64px; font-size: 24px; }
.badge.c-red { background: var(--red-ink); color: #FFFFFF; }
.badge.c-blue { background: var(--blue-ink); color: #FFFFFF; }
.badge.c-white { background: var(--white); color: var(--ink); border: 2px solid var(--white-edge); }
.badge.c-yellow { background: var(--yellow); color: var(--ink); }

.dot, .tab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.c-red.dot, .c-red.tab-dot { background: var(--red); }
.c-blue.dot, .c-blue.tab-dot { background: var(--blue); }
.c-yellow.dot, .c-yellow.tab-dot { background: var(--yellow); }
.c-white.dot, .c-white.tab-dot { background: var(--white); box-shadow: inset 0 0 0 1px var(--white-edge); }

/* ---------- ボタン・フォーム ---------- */

.btn {
  min-height: 48px; padding: 10px 20px;
  border: none; border-radius: 14px;
  background: var(--ink); color: var(--card);
  font: inherit; font-size: 17px; font-weight: 700; letter-spacing: 0.04em;
  cursor: pointer;
}
.btn-sub { background: var(--card); color: var(--ink); border: 2px solid var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 400; font-size: 15px; }
.btn:active { transform: translateY(1px); }
.btn-icon {
  min-width: 48px; min-height: 48px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 26px; line-height: 1; cursor: pointer;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 140px; }

.form label { font-weight: 700; }
.form input {
  display: block; width: 100%; height: 48px; padding: 0 12px;
  border: 1px solid var(--white-edge); border-radius: 12px;
  background: #FFFFFF; color: var(--ink);
  font: inherit; font-size: 17px; line-height: 1.4;
}
/* 日付・数字の欄は中身に合った幅にする。iPhone 独自の見た目（高さ・中央寄せ）も外す */
.form input[type="date"],
.form input[type="number"] {
  max-width: 14em;
  -webkit-appearance: none; appearance: none;
}
.form input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.form .btn { justify-self: start; min-width: 10em; }
.form .actions .btn { width: auto; }

.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--soft); border-radius: 14px; padding: 4px;
}
.segmented button {
  min-height: 44px; border: none; border-radius: 10px; background: transparent;
  font: inherit; font-size: 16px; color: var(--ink); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--card); font-weight: 700; box-shadow: var(--shadow); }

/* ---------- こんしゅう・ずかん（開け閉めできるカード） ---------- */

details.card { gap: 10px; }
details.card > summary {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; list-style: none; min-height: 44px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after {
  content: "＋"; margin-left: auto; color: var(--muted); flex: none;
}
details.card[open] > summary::after { content: "－"; }
.day-main { display: grid; line-height: 1.5; }
.day-date { font-size: 13px; color: var(--muted); }
.day-name { font-weight: 700; }
.day-meta { font-size: 13px; color: var(--muted); }

.tone-no {
  flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--soft); font-weight: 700;
}

.mini { display: flex; align-items: center; gap: 12px; }
.mini p { line-height: 1.5; }

.plain-list { list-style: none; margin: 0; padding: 16px; }
.plain-list li + li { border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- カレンダー ---------- */

.cal-nav { display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-size: 18px; }
.cal { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.cal th { font-size: 12px; font-weight: 400; color: var(--muted); padding: 2px 0; }
.cal th.sun { color: var(--red-ink); }
.cal th.sat { color: var(--blue-ink); }
.cal td { padding: 0; }
.cal-cell {
  position: relative; width: 100%; min-height: 52px;
  display: grid; align-content: center; justify-items: center; gap: 0;
  padding: 4px 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; cursor: pointer;
}
.cal-cell .cd { font-size: 15px; font-weight: 700; line-height: 1.3; }
.cal-cell .ck { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); line-height: 1.3; }
.cal-cell .cb { position: absolute; top: 1px; right: 4px; font-size: 11px; line-height: 1.2; }
.cal-cell.is-today { border: 2px solid var(--ink); }
.cal-cell.is-selected { background: var(--soft); }
.legend { padding: 0 4px; }

/* ---------- 下部ナビ ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar a {
  min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; color: var(--muted); text-decoration: none; letter-spacing: -0.02em; white-space: nowrap;
}
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabbar a[aria-current="page"] .tab-dot { width: 12px; height: 12px; }
.header-link[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* ---------- お知らせ ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--card);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  transition: opacity 0.2s, transform 0.2s; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- メールプレビュー画面 ---------- */

.preview-banner {
  background: var(--yellow); color: var(--ink); font-weight: 700;
  text-align: center; padding: 8px 12px; border-radius: 12px;
}
.mail {
  white-space: pre-wrap; font-size: 15px; line-height: 1.8;
  background: #FFFFFF; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
}
.mail-subject { font-weight: 700; }
.form select {
  width: 100%; min-height: 48px; padding: 8px 12px;
  border: 1px solid var(--white-edge); border-radius: 12px;
  background: #FFFFFF; color: var(--ink); font: inherit; font-size: 17px;
}
.preview-page { padding-bottom: 24px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
