/* ===========================
   ふりがなメーカー — yorozu-craft 共通の和紙風の配色
   色はトークン（--bg / --card / --text / --muted / --accent / --border）だけを使う。
   ダークモードは端末の設定に自動で合わせる（prefers-color-scheme。手動切替は付けない）
   =========================== */
:root {
  color-scheme: light dark;
  --bg: #f0ebe0;
  --bg-2: #e6dfd0;
  --card: #faf6ee;
  --text: #3a3025;
  --muted: #6e604f;
  --accent: #8b4513;
  --accent-soft: #f3e6d8;
  --border: #cfc0a0;
  --shadow: rgba(58, 48, 37, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1814;
    --bg-2: #25201a;
    --card: #2b251e;
    --text: #ece4d6;
    --muted: #b9ab96;
    --accent: #e0a066;
    --accent-soft: #3a2e22;
    --border: #4a3f33;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  /* README「ツールを追加するとき」9: 端末のフォント。Web フォントは読まない */
  font-family: "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

a { color: var(--accent); }

/* ヘッダー */
.app-header {
  text-align: center;
  padding: 1.4rem 1rem 1.1rem;
  background: var(--bg-2);
  border-bottom: 2px solid var(--border);
}
.app-header h1 { font-size: 1.45rem; color: var(--accent); line-height: 1.4; }
.app-header .subtitle { font-size: 0.88rem; color: var(--muted); margin-top: 0.3rem; }

/* レイアウト */
.app-main { max-width: 680px; margin: 0 auto; padding: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px var(--shadow);
}
.card h2 {
  font-size: 1.02rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.9rem;
}

/* 入力 */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.field .hint { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.4rem; }
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%;
  max-width: 16rem;
  padding: 0.45rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
}

.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--card);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 読みもの（guide.html） */
.content h3 { font-size: 0.95rem; margin: 1rem 0 0.3rem; }
.content p, .content li { font-size: 0.9rem; }
.content p + p { margin-top: 0.5rem; }
.content ul, .content ol { padding-left: 1.3rem; margin: 0.3rem 0; }
.faq dt { font-weight: 600; margin-top: 0.9rem; font-size: 0.92rem; }
.faq dt::before { content: 'Q. '; color: var(--accent); }
.faq dd { font-size: 0.88rem; color: var(--muted); padding: 0.2rem 0 0.5rem 1.2rem; border-bottom: 1px solid var(--border); }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.2rem; font-size: 0.9rem; }
.info-list dt { font-weight: 600; }
.info-list dd { color: var(--muted); }
.small { font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }

/* フッター */
.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.footer-nav ul { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-bottom: 0.6rem; }
.footer-nav a { color: var(--muted); text-decoration: none; }
.footer-nav a:hover, .footer-nav a[aria-current="page"] { color: var(--accent); }

@media (max-width: 480px) {
  .app-header h1 { font-size: 1.2rem; }
}

/* ===========================
   ふりがなメーカー
   =========================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.lang-switch { font-size: 0.82rem; margin-top: 0.35rem; }
.big-label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.card textarea {
  width: 100%; padding: 0.55rem 0.6rem; font-size: 1rem; line-height: 1.7; font-family: inherit;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); resize: vertical;
}
#src { min-height: 8.5rem; }
.counter { margin: 0.2rem 0 0.6rem; }
.warn { color: #b3261e; }
@media (prefers-color-scheme: dark) { .warn { color: #ffb4a9; } }
.field .inline, label.inline { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 400; min-height: 44px; margin-right: 0.8rem; }
.field .label { display: block; font-weight: 600; font-size: 0.95rem; }
.field input[type="checkbox"], .field input[type="radio"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.field select { min-height: 44px; }
#out { font-size: 0.85rem; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }

.btn { min-height: 44px; }
.btn-sub { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.btn-small { min-height: 36px; padding: 0.25rem 0.8rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 0.9rem; }   /* 見本の下（SCREEN.md 1.1: 文 → 見本 → 印刷・コピー） */
.copy-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.copy-group select { min-height: 44px; max-width: 100%; padding: 0.4rem; font-size: 0.9rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0.6rem 0; }
.h3 { font-size: 0.95rem; margin: 1rem 0 0.3rem; }

/* 状態の行: 高さを先に取っておき、辞書の読み込み中・解析後で画面がずれないようにする（CLS 0） */
.status { min-height: 4.2rem; margin-top: 0.8rem; font-size: 0.85rem; color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--bg-2); border: 1px solid var(--border); overflow: hidden; margin-top: 0.3rem; }
.bar-in { height: 100%; width: 2%; background: var(--accent); transition: width 0.2s; }

/* 見本（紙）: ダークモードでも白（SCREEN 5 章） */
.sheet {
  background: #fff; color: #1a1a1a; border: 1px solid #d8d0bf; border-radius: 4px; padding: 1rem 1.1rem;
  line-height: 2.3; font-size: 1.05rem; overflow-wrap: anywhere; word-break: normal; line-break: strict;
}
.sheet.size-l { font-size: 1.35rem; }
.sheet.size-xl { font-size: 1.7rem; }
.sheet rt { font-size: 50%; color: #333; }
.sheet ruby { ruby-position: over; }
.sheet-empty { color: #6b6b6b; font-size: 0.95rem; }
.sheet .w { cursor: pointer; border-radius: 2px; }
.sheet .w:hover, .sheet .w:focus-visible { background: #fdf0d8; outline: none; }
.sheet .w.m { text-decoration: underline dotted #9a5b1f; text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.sheet .w.user rt { color: #0b5d1e; }
#sec-preview .hint { font-size: 0.8rem; color: var(--muted); margin: -0.4rem 0 0.5rem; }

.dict-list { list-style: none; padding: 0; margin: 0.4rem 0; }
.dict-list li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.25rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.dict-list li .btn { margin-left: auto; }
.bookmarklet { display: inline-block; padding: 0.4rem 0.9rem; border: 1px dashed var(--accent); border-radius: 6px; text-decoration: none; font-weight: 700; }
details.card > summary { cursor: pointer; font-weight: 700; color: var(--accent); min-height: 32px; }
details.card[open] > summary { margin-bottom: 0.6rem; }

/* 直すダイアログ・大きな字で読む */
dialog { border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); padding: 1rem; max-width: min(28rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.fix-word { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.2rem; }
.fix-dialog input[type="text"] { width: 100%; min-height: 44px; font-size: 1.1rem; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); }
.fix-dialog label { display: block; font-weight: 600; margin-top: 0.4rem; }
.reading-view { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; padding: 0; background: #fff; }
.rv-bar { position: sticky; top: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 0.5rem; background: var(--bg-2); border-bottom: 1px solid var(--border); }
.rv-body { border: 0; border-radius: 0; font-size: 1.6rem; line-height: 2.4; padding: 1rem 1.2rem 3rem; max-width: 46rem; margin: 0 auto; }

/* 固定バー（SCREEN D59: 上端。下端はアンカー広告が使う） */
.fixbar { position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: 48px; background: var(--card); border-bottom: 2px solid var(--accent); box-shadow: 0 2px 8px var(--shadow); }
.fixbar-in { max-width: 680px; margin: 0 auto; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 1rem; }
.fixbar a { font-weight: 700; text-decoration: none; }

/* 使い方ページ */
.content table { border-collapse: collapse; font-size: 0.85rem; margin: 0.4rem 0; width: 100%; }
.content th, .content td { border: 1px solid var(--border); padding: 0.3rem 0.45rem; text-align: left; vertical-align: top; }
.content th { background: var(--bg-2); }
.content details { margin-top: 0.5rem; font-size: 0.88rem; }
.content details summary { cursor: pointer; color: var(--accent); }
.demo-ruby { background: #fff; color: #1a1a1a; padding: 0.5rem 0.7rem; border-radius: 4px; line-height: 2.2; }

/* 印刷用の紙（画面では出さない） */
.print-sheet { display: none; }

@media print {
  @page { size: A4; margin: 15mm 15mm 14mm; }
  html, body { background: #fff !important; margin: 0; padding: 0; }
  body.tool-page > :not(#print-sheet) { display: none !important; }
  .print-sheet { display: block !important; color: #000; }
  .print-sheet .sheet { border: 0; padding: 0; background: #fff; color: #000; }
  .print-sheet.size-m .sheet { font-size: 14pt; line-height: 2.3; }
  .print-sheet.size-l .sheet { font-size: 18pt; line-height: 2.3; }
  .print-sheet.size-xl .sheet { font-size: 24pt; line-height: 2.2; }
  .print-sheet .sheet rt { color: #000; }
  .print-sheet .w.m { text-decoration: underline dotted #000; }
  html.print-vertical { writing-mode: vertical-rl; }
  html.print-vertical .credit { text-align: left; margin: 0 4mm 0 0; }
  .print-sheet.vertical .tcy { text-combine-upright: all; }
  .credit { text-align: right; font-size: 7.5pt; color: #333; margin-top: 4mm; }
  .fixbar { display: none !important; }
  /* 広告は印刷に出さない（gakushu-print と同じ） */
  ins.adsbygoogle, .google-auto-placed, iframe[id^="aswift"], iframe[id^="google_ads"] { display: none !important; }
}
