/* =========================================================
   らくらくA4 --- 見た目の設定
   読みやすさと押しやすさを最優先にしています。
   ========================================================= */

/* ---------- 色の決まり（ここだけ変えれば全体に反映されます） ---------- */
:root {
  --blue:   #1769AA; /* 印刷・実行 */
  --purple: #8054B8; /* AI */
  --gray:   #64748B; /* 元に戻す・取消 */
  --text:   #0f172a;
  --bg:     #eef2f6;
  --card:   #ffffff;
  --border: #94a3b8;
}

/* hidden 属性が付いた要素は必ず隠す */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic",
               "Meiryo", sans-serif;
  font-size: 20px;
  line-height: 1.6;
}

.view {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---------- ヘッダー ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo { width: 56px; height: 56px; flex: none; }
h1 { margin: 0; font-size: 32px; line-height: 1.2; }

.lead { margin: 12px 0 20px; font-size: 20px; }

/* ---------- 枠（カード） ---------- */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
}

.section-title {
  display: block;
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 700;
}

/* ---------- 入力欄 ---------- */
textarea {
  display: block;
  width: 100%;
  min-height: 280px;
  padding: 14px;
  font: inherit;
  font-size: 24px;
  line-height: 1.6;
  color: var(--text);
  background: #fff;
  border: 3px solid var(--gray);
  border-radius: 12px;
  resize: vertical;
}
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(23, 105, 170, 0.25);
}

.status-line {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 8px 0 0;
  font-size: 18px;
  color: #334155;
}

/* ---------- ボタン ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 76px;
  margin: 0 0 16px;
  padding: 12px 16px;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn svg {
  width: 34px;
  height: 34px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-blue   { background: var(--blue); }
.btn-purple { background: var(--purple); }
.btn-gray   { background: var(--gray); }

/* 押している間は少し沈んで暗くなる */
.btn:active:not(:disabled) {
  transform: translateY(2px);
  filter: brightness(0.85);
}
.btn:focus-visible,
.back-link:focus-visible {
  outline: 4px solid #f59e0b;
  outline-offset: 3px;
}
/* 押せない状態ははっきり灰色にする */
.btn:disabled {
  background: #cbd5e1;
  color: #475569;
  cursor: not-allowed;
}

.note { margin: 0 0 12px; font-size: 18px; color: #334155; }

.message {
  margin: 12px 0 0;
  padding: 14px;
  font-size: 22px;
  font-weight: 700;
  border-radius: 12px;
  background: #e0f2fe;
  color: #0c4a6e;
}
.message.is-error { background: #fee2e2; color: #7f1d1d; }

/* ---------- 確認画面 ---------- */
.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 0 8px;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  color: var(--gray);
  background: none;
  border: none;
  cursor: pointer;
}
.back-link svg {
  width: 28px; height: 28px;
  fill: none; stroke: currentColor; stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.confirm-title { margin: 4px 0 0; font-size: 28px; }

.demo-banner {
  margin: 0 0 16px;
  padding: 12px;
  font-size: 18px;
  font-weight: 700;
  background: #fef3c7;
  color: #78350f;
  border-radius: 12px;
}

/* 下に固定して、いつでも押せるようにする */
.sticky-actions {
  position: sticky;
  bottom: 0;
  margin-top: 20px;
  padding: 16px 0 4px;
  background: linear-gradient(to bottom, rgba(238, 242, 246, 0), var(--bg) 18px);
}

/* =========================================================
   A4プレビュー（画面でも印刷でも同じ「mm」サイズで作る）
   画面では、スマホの幅に合わせて縮小して見せるだけ。
   ========================================================= */
/* 白い紙が白い枠に溶け込まないよう、プレビューの枠は灰色にする（印刷では無効） */
.preview-card { background: #cbd5e1; }
.preview-card .section-title { color: var(--text); }

.preview-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
}
.page-set {
  width: 210mm;
  transform-origin: top left;
  transform: scale(var(--s, 0.4)); /* 縮小率は script.js が入れる */
}

.page {
  position: relative;
  width: 210mm;
  height: 297mm;
  padding: 20mm;               /* 紙の余白（上下左右）*/
  margin-bottom: 10mm;         /* 画面で見るときの、ページ同士のすき間 */
  background: #fff;
  color: #000;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.35);
}
.page:last-child { margin-bottom: 0; }

.page-text {
  white-space: pre-wrap;       /* 改行をそのまま守る */
  overflow-wrap: anywhere;     /* 長い文字列も紙の外に出さない */
  line-break: strict;          /* 日本語の禁則処理（句読点が行頭に来にくい） */
  line-height: 1.7;
  font-weight: 500;
}
.page-text.is-empty { color: #94a3b8; }

.page-number {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8mm;
  text-align: center;
  font-size: 12pt;
  color: #475569;
}

/* 文字の大きさを測るための、見えない作業用の箱（script.jsが使う） */
.measure-box {
  position: absolute;
  left: -99999px;
  top: 0;
  width: 170mm;                /* 210mm - 余白20mm×2 */
  visibility: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-break: strict;
  line-height: 1.7;
  font-weight: 500;
  font-family: inherit;
}

/* =========================================================
   印刷用の設定：画面用の部品は消して、用紙だけを出す
   ========================================================= */
@page { size: A4 portrait; margin: 0; }

@media print {
  .no-print { display: none !important; }

  html, body { background: #fff; }
  .view { max-width: none; margin: 0; padding: 0; }
  .card { background: none; padding: 0; margin: 0; border-radius: 0; }

  .preview-wrap {
    height: auto !important;
    overflow: visible;
  }
  .page-set {
    transform: none;
    width: 210mm;
  }
  .page {
    height: 296mm;             /* 297mmちょうどだと白紙が出ることがあるため少し小さく */
    margin: 0;
    box-shadow: none;
    break-after: page;
  }
  .page:last-child { break-after: auto; }
}
