:root {
  --primary: #1a6ee0;
  --primary-dark: #1257b8;
  --ink: #1f2733;
  --muted: #66707d;
  --line: #d9dee5;
  --bg: #f4f6f9;
  --paper: #ffffff;

  /* 請求書プレビュー/PDF専用カラー(テーマに左右されず常に白基調) */
  --invoice-paper: #ffffff;
  --invoice-line: #d9dee5;

  /* 記事ページ用アクセントカラー */
  --accent-bg: #eaf2fe;
  --accent-border: #bcd4f5;
  --table-head-bg: #f0f4f9;
  --note-bg: #fff8e6;
  --note-border: #f0dca0;

  /* ニューモフィズム用ソフトシャドウ */
  --neu-dark: rgba(163, 177, 198, 0.5);
  --neu-light: rgba(255, 255, 255, 0.9);
  --neu-out: 7px 7px 16px var(--neu-dark), -7px -7px 16px var(--neu-light);
  --neu-out-sm: 4px 4px 10px var(--neu-dark), -4px -4px 10px var(--neu-light);
  --neu-in: inset 4px 4px 9px var(--neu-dark), inset -4px -4px 9px var(--neu-light);
  --neu-in-sm: inset 2px 2px 6px var(--neu-dark), inset -2px -2px 6px var(--neu-light);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #5b9dff;
    --primary-dark: #87b8ff;
    --ink: #e7ebf1;
    --muted: #97a3b3;
    --line: #2b323d;
    --bg: #181c24;
    --paper: #1f2530;

    --neu-dark: rgba(0, 0, 0, 0.55);
    --neu-light: rgba(255, 255, 255, 0.045);

    --accent-bg: #1d2c45;
    --accent-border: #2f4566;
    --table-head-bg: #232b38;
    --note-bg: #332b16;
    --note-border: #4d4221;
  }
}

/* 手動テーマ切り替え(localStorageに保存。OS設定より優先) */
:root[data-theme="dark"] {
  --primary: #5b9dff;
  --primary-dark: #87b8ff;
  --ink: #e7ebf1;
  --muted: #97a3b3;
  --line: #2b323d;
  --bg: #181c24;
  --paper: #1f2530;

  --neu-dark: rgba(0, 0, 0, 0.55);
  --neu-light: rgba(255, 255, 255, 0.045);

  --accent-bg: #1d2c45;
  --accent-border: #2f4566;
  --table-head-bg: #232b38;
  --note-bg: #332b16;
  --note-border: #4d4221;
}
:root[data-theme="light"] {
  --primary: #1a6ee0;
  --primary-dark: #1257b8;
  --ink: #1f2733;
  --muted: #66707d;
  --line: #d9dee5;
  --bg: #f4f6f9;
  --paper: #ffffff;

  --neu-dark: rgba(163, 177, 198, 0.5);
  --neu-light: rgba(255, 255, 255, 0.9);

  --accent-bg: #eaf2fe;
  --accent-border: #bcd4f5;
  --table-head-bg: #f0f4f9;
  --note-bg: #fff8e6;
  --note-border: #f0dca0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
}
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
a { color: var(--primary); }

/* ---------- ヘッダー ---------- */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; transition: height 0.15s ease; }
.site-header:not(.is-scrolled) .header-inner { height: 84px; }
.logo { display: inline-flex; align-items: baseline; font-size: 1.3rem; font-weight: 800; text-decoration: none; color: var(--ink); transition: font-size 0.15s ease; }
.site-header:not(.is-scrolled) .logo { font-size: 1.6rem; }
.logo .logo-product { color: var(--ink); font-size: 0.88em; position: relative; top: -0.07em; }
.logo .logo-brand { font-family: "Montserrat", sans-serif; font-weight: 500; font-style: italic; font-size: 1.15em; line-height: 1; letter-spacing: -0.03em; color: var(--primary); margin-right: 0.2em; }
.site-header nav a { margin-left: 18px; text-decoration: none; color: var(--muted); font-size: 0.92rem; }
.site-header nav a:hover { color: var(--primary); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin-left: 18px; vertical-align: middle;
  background: transparent; border: 1px solid var(--line); border-radius: 50%;
  color: var(--muted); cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- ヒーロー ---------- */
.hero { background: linear-gradient(160deg, #eaf2fe 0%, #f8fafc 100%); text-align: center; padding: 56px 0 48px; }
@media (prefers-color-scheme: dark) {
  .hero { background: linear-gradient(160deg, #1d2433 0%, #181c24 100%); }
}
:root[data-theme="dark"] .hero { background: linear-gradient(160deg, #1d2433 0%, #181c24 100%); }
:root[data-theme="light"] .hero { background: linear-gradient(160deg, #eaf2fe 0%, #f8fafc 100%); }
.hero h1 { font-size: 2.6rem; font-weight: 900; line-height: 1.35; margin: 0 0 16px; letter-spacing: 0.01em; }
.hero h1 .accent { color: var(--primary); }
.hero-sub { color: var(--muted); margin-bottom: 26px; }
.hero-points { list-style: none; padding: 0; margin: 26px 0 0; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 0.88rem; }
.hero-points li { border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; }

.btn-primary {
  display: inline-block; background: var(--primary); color: #fff; border: none;
  padding: 13px 30px; border-radius: 14px; font-size: 1.05rem; font-weight: 700;
  text-decoration: none; cursor: pointer;
  box-shadow: var(--neu-out), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: background 0.15s, box-shadow 0.1s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { box-shadow: var(--neu-in); transform: translateY(1px); }
.btn-secondary {
  display: inline-block; background: transparent; color: var(--ink); border: 1px solid var(--line);
  padding: 10px 20px; border-radius: 12px; font-size: 0.95rem; cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.btn-secondary:hover { background: var(--bg); border-color: var(--muted); }

/* ---------- ツールレイアウト ---------- */
.tool-layout { display: grid; grid-template-columns: 460px 1fr; gap: 28px; padding-top: 36px; padding-bottom: 48px; align-items: start; }
@media (max-width: 980px) { .tool-layout { grid-template-columns: 1fr; } }

/* フォーム */
.form-pane { background: var(--bg); border-radius: 18px; padding: 22px; box-shadow: var(--neu-out); }
.form-group { border-bottom: 1px solid var(--line); padding: 10px 0 16px; }
.form-group summary { font-size: 0.92rem; font-weight: 700; cursor: pointer; padding: 6px 0; }
.form-pane label { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
.form-pane input[type="text"], .form-pane input[type="date"], .form-pane input[type="number"],
.form-pane textarea, .form-pane select {
  width: 100%; padding: 9px 10px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 0.95rem; font-family: inherit;
  background: var(--paper); color: var(--ink);
}
.form-pane input:focus, .form-pane textarea:focus, .form-pane select:focus { outline: 2px solid var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.sample-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.form-pane-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.btn-sample {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font-size: 0.82rem; color: var(--muted); cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.btn-sample:hover { color: var(--ink); background: var(--bg); border-color: var(--muted); }
.btn-sample .icon { width: 15px; height: 15px; flex: none; }

/* 品目行 */
.item-row { display: grid; grid-template-columns: 1fr 64px 96px 76px 30px; gap: 6px; margin-top: 8px; align-items: center; }
.item-row input, .item-row select { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; background: var(--paper); color: var(--ink); }
.item-del { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 2px; }
.item-del:hover { color: #d33; }
#addItem { margin-top: 12px; }
.options-row { margin-top: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.92rem !important; color: var(--ink) !important; }
.check input { width: auto !important; }

.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.privacy-note { font-size: 0.78rem; color: var(--muted); margin-top: 12px; }

/* ---------- 請求書プレビュー ---------- */
.preview-pane { position: sticky; top: 76px; }
.invoice-sheet {
  background: var(--invoice-paper); border: 1px solid var(--invoice-line); border-radius: 4px;
  padding: 14mm 15mm; min-height: 270mm; max-width: 210mm; margin: 0 auto;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  font-size: 8.5pt; line-height: 1.5; color: #1d2125;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.inv-title { text-align: center; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.35em; margin: 0 0 24px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.inv-client { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.inv-client-name { font-size: 1.05rem; font-weight: 700; border-bottom: 1px solid #000; display: inline-block; padding: 0 24px 3px 2px; margin: 0 0 10px; max-width: 100%; word-break: break-word; box-sizing: border-box; }
.inv-subject { margin: 4px 0; font-size: 0.85rem; word-break: break-word; }
.inv-client > p:last-child:not(.inv-total-label) { margin-top: 8px; color: #555; font-size: 0.8rem; }
.inv-issuer { text-align: left; font-size: 0.75rem; line-height: 1.5; flex: 0 0 220px; width: 220px; min-width: 0; }
.inv-issuer p { margin: 2px 0; word-break: break-word; overflow-wrap: break-word; }
.inv-issuer-name { font-weight: 700; font-size: 0.92rem; margin-top: 10px !important; }
.inv-meta { border-collapse: collapse; margin-left: auto; margin-bottom: 16px; width: 100%; table-layout: fixed; }
.inv-meta th { width: 6.5em; white-space: nowrap; }
.inv-meta td { white-space: nowrap; }
.inv-meta th, .inv-meta td { border: 1px solid #d3d8de; padding: 4px 6px; font-size: 0.7rem; font-weight: normal; line-height: 1.3; }
.inv-meta th { background: #f4f6f9; text-align: left; font-weight: 500; }

.inv-total-label {
  display: flex; align-items: baseline; gap: 10px;
  background: #f4f6f9; border-radius: 4px;
  padding: 8px 14px; margin: 10px 0 0; font-size: 0.85rem; font-weight: 700;
  width: fit-content;
}
.inv-total-label strong { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.02em; }

.inv-items { width: 100%; border-collapse: collapse; margin-top: 4px; }
.inv-items th, .inv-items td { border: 1px solid #d3d8de; padding: 5px 8px; font-size: 0.78rem; }
.inv-items thead th { background: #2b333d; color: #fff; font-weight: 700; border-color: #2b333d; }
.inv-items tbody td { line-height: 1.4; }
.inv-items .col-name { width: 44%; }
.inv-items td:nth-child(2), .inv-items td:nth-child(4) { text-align: center; }
.inv-items td:nth-child(3), .inv-items td:nth-child(5) { text-align: right; font-variant-numeric: tabular-nums; }

.inv-summary { display: flex; justify-content: flex-end; margin-top: 14px; }
.inv-summary table { border-collapse: collapse; min-width: 240px; }
.inv-summary th, .inv-summary td { border: 1px solid #d3d8de; padding: 5px 12px; font-size: 0.8rem; }
.inv-summary th { background: #f4f6f9; text-align: left; font-weight: 500; }
.inv-summary td { text-align: right; font-variant-numeric: tabular-nums; }
.inv-summary tr.total th, .inv-summary tr.total td { font-weight: 700; font-size: 0.88rem; background: #eef2f7; }

.inv-bank, .inv-notes { margin-top: 22px; }
.inv-bank h3, .inv-notes h3 { font-size: 0.78rem; font-weight: 700; margin: 0 0 6px; }
.inv-bank p, .inv-notes p { margin: 0; font-size: 0.8rem; line-height: 1.5; white-space: pre-wrap; }
.inv-notes { border: 1px solid var(--invoice-line); border-radius: 4px; padding: 10px 14px; }

.inv-watermark { text-align: right; color: #aaa; font-size: 9pt; margin-top: 16px; }
.inv-watermark .wm-brand { font-family: "Montserrat", sans-serif; font-weight: 500; font-style: italic; letter-spacing: -0.03em; margin-right: 0.15em; }
.inv-watermark .wm-product { font-weight: 700; }
.no-screen { display: none; }

@media screen {
  .invoice-sheet { font-size: 7.5pt; }
}

/* ---------- LPセクション ---------- */
.content-section { background: var(--paper); border-top: 1px solid var(--line); padding: 48px 0; }
.content-section h2 { font-size: 1.5rem; margin-top: 0; }
.steps { padding-left: 1.4em; }
.steps li { margin-bottom: 10px; }
.faq dt { font-weight: 700; margin-top: 18px; }
.faq dt::before { content: "Q. "; color: var(--primary); }
.faq dd { margin: 6px 0 0 0; color: var(--muted); }
.faq dd::before { content: "A. "; color: #d08a00; }

.site-footer { padding: 28px 0 40px; text-align: center; color: var(--muted); font-size: 0.85rem; }
.disclaimer { font-size: 0.75rem; }

/* ---------- モバイル対応 ---------- */
@media (max-width: 600px) {
  .container { padding: 0 12px; }
  .tool-layout > * { min-width: 0; }

  /* ヘッダー: ロゴを縮小しナビを折り返す */
  .header-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 6px 0; }
  .site-header:not(.is-scrolled) .header-inner { height: auto; }
  .logo { font-size: 1.15rem; white-space: nowrap; }
  .site-header:not(.is-scrolled) .logo { font-size: 1.15rem; }
  .site-header nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; width: 100%; justify-content: flex-end; }
  .site-header nav a { margin-left: 0; font-size: 0.82rem; }
  .theme-toggle { margin-left: 4px; }

  /* ヒーロー */
  .hero { padding: 32px 0 32px; }
  .hero h1 { font-size: 1.9rem; }
  .hero-points { gap: 8px; }
  .hero-points li { padding: 6px 12px; font-size: 0.8rem; }

  /* フォーム */
  .form-pane { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; gap: 0; }
  .item-row { grid-template-columns: minmax(0,1fr) 50px 64px 60px 22px; gap: 4px; }
  .item-row input, .item-row select { padding: 6px 4px; font-size: 0.82rem; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn-primary, .form-actions .btn-secondary { flex: 1 1 100%; text-align: center; }

  /* 請求書プレビュー */
  .preview-pane { position: static; }
  .invoice-sheet { padding: 5mm; font-size: 6.3pt; }
  .inv-head { flex-direction: column; }
  .inv-issuer { flex: 1 1 auto; width: auto; }
  .inv-meta { margin-left: 0; }
}

/* ---------- 印刷(PDF出力) ---------- */
@media print {
  .no-print { display: none !important; }
  .no-screen { display: block; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .tool-layout { display: block; padding: 0; }
  .preview-pane { position: static; }
  .invoice-sheet {
    border: none; box-shadow: none; border-radius: 0;
    padding: 0; min-height: auto; max-width: none; margin: 0;
  }
  @page { size: A4; margin: 14mm; }
}
