:root {
  --navy: #003a73;
  --navy-dark: #002a54;
  --blue: #009fe6;
  --blue-soft: #e3f4fd;
  --ink: #1c2b36;
  --gray: #5b6b78;
  --line: #dde5ec;
  --bg: #f5f8fa;
  --white: #ffffff;
  --accent: #ff7a45;
  --green: #2bb673;
  --red: #e0443a;
  --teal: #0c8599;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0, 42, 84, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Noto Sans JP', 'Inter', sans-serif; color: var(--ink); background: var(--bg); line-height: 1.8; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- header / hero ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.header-inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; height: 58px; }
.logo { color: #fff; font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.logo-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--teal); color: #fff; font-weight: 800; font-size: 16px; flex-shrink: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a { color: #cfe3f5; text-decoration: none; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; transition: .15s; }
.nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.nav .nav-home { background: rgba(255,255,255,.14); color: #fff; font-weight: 700; border: 1px solid rgba(255,255,255,.25); }
.nav .nav-home:hover { background: var(--teal); border-color: var(--teal); }

.hero { background: linear-gradient(135deg, var(--navy) 0%, #00518f 55%, #0c8599 100%); color: #fff; padding: 56px 0 48px; }
.hero .container { max-width: 980px; }
.hero-eyebrow { font-family: 'Inter', sans-serif; font-weight: 600; font-size: 12px; letter-spacing: .2em; color: #8fe3ef; margin: 0 0 10px; }
.hero h1 { font-size: 34px; font-weight: 900; margin: 0 0 16px; letter-spacing: .02em; }
.hero-lead { font-size: 15px; color: #d7e7f5; margin: 0 0 24px; }
.hero-lead strong { color: #fff; }
.hero-steps { display: flex; gap: 10px; flex-wrap: wrap; }
.step-chip { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); color: #fff; font-size: 13px; font-weight: 700; padding: 8px 16px; border-radius: 999px; }

/* ---------- usage lesson ---------- */
.lesson { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; margin: 28px 0; max-width: 980px; margin-left: auto; margin-right: auto; }
.lesson-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.step-badge { background: var(--teal); color: #fff; font-family: 'Inter', sans-serif; font-weight: 800; font-size: 12px; letter-spacing: .08em; padding: 4px 12px; border-radius: 999px; }
.lesson h2 { font-size: 20px; font-weight: 900; color: var(--navy); margin: 0; }
.lesson-desc { color: var(--gray); font-size: 14px; margin: 8px 0 0; }
.lesson-desc strong { color: var(--navy); }

/* ---------- builder layout ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; margin: 28px 0; }
.builder-form { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.form-block + .form-block { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-h { font-size: 16px; color: var(--navy); margin: 0 0 14px; }
.form-h-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.form-h-row .form-h { margin: 0; }
.form-hint { font-size: 12px; color: var(--gray); margin: 0 0 14px; line-height: 1.6; }
.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12.5px; font-weight: 700; color: var(--navy); }
.fld span { font-size: 12px; }
.fld input, .fld textarea, .fld select { font-family: inherit; font-size: 14px; font-weight: 500; color: var(--ink); border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; width: 100%; }
.fld textarea { resize: vertical; line-height: 1.6; }
.fld input:focus, .fld textarea:focus, .fld select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(12,133,153,.12); }
.fld-row { display: flex; gap: 10px; }
.fld-row .fld { flex: 1; }

/* 作品の編集カード */
.work-edit { border: 1.5px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: var(--bg); }
.work-edit-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.work-edit-no { font-size: 12.5px; font-weight: 800; color: var(--teal); }
.work-edit-tools { display: flex; gap: 4px; }
.work-edit-tools button { font-family: inherit; border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 6px; width: 30px; height: 26px; cursor: pointer; font-size: 12px; line-height: 1; }
.work-edit-tools button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.work-edit-tools button:disabled { opacity: .3; cursor: default; }
.work-edit-tools .del:hover { border-color: var(--red); color: var(--red); }
.img-pick { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.img-thumb { width: 76px; height: 60px; border-radius: 6px; border: 1px solid var(--line); background: #fff center/cover no-repeat; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #b6c4ce; }
.img-pick-btns { display: flex; flex-direction: column; gap: 5px; }
.img-pick label.filebtn { font-size: 12.5px; font-weight: 700; color: var(--teal); border: 1.5px solid var(--teal); background: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; text-align: center; }
.img-pick label.filebtn:hover { background: #e6f6f9; }
.img-pick input[type=file] { display: none; }
.img-pick .img-clear { font-size: 11.5px; color: var(--gray); background: none; border: none; cursor: pointer; text-decoration: underline; }

/* ---------- preview ---------- */
.pf-preview { background: #eef2f5; border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 0 18px; min-width: 0; }
.pf-preview-head { position: sticky; top: 58px; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.pf-prev-title { font-weight: 900; color: var(--navy); font-size: 14px; }
.pf-prev-status { font-size: 11.5px; color: var(--green); font-weight: 700; }
.pf-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
#pf-doc { display: flex; flex-direction: column; gap: 18px; padding: 18px; }

/* A4比率のページ */
.pf-page { --accent: var(--teal); background: #fff; border-radius: 6px; box-shadow: 0 4px 18px rgba(0,42,84,.12); aspect-ratio: 1 / 1.414; padding: 8% 9%; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.pf-page.cover { color: #fff; justify-content: space-between; padding: 12% 10%; }
.pf-page.cover::before { content: ""; position: absolute; inset: 0; background: linear-gradient(150deg, var(--accent) 0%, rgba(0,0,0,.35) 160%); z-index: 0; }
.pf-page.cover > * { position: relative; z-index: 1; }
.cover-eyebrow { font-family: 'Inter', sans-serif; letter-spacing: .35em; font-size: 12px; font-weight: 600; opacity: .85; }
.cover-main .cover-name { font-size: 34px; font-weight: 900; line-height: 1.2; margin: 0; }
.cover-main .cover-dept { font-size: 14px; font-weight: 700; opacity: .9; margin: 8px 0 0; }
.cover-main .cover-catch { font-size: 16px; font-weight: 500; opacity: .95; margin: 18px 0 0; line-height: 1.6; }
.cover-foot { font-size: 11px; opacity: .8; }

.pf-page-h { font-size: 13px; font-weight: 800; color: var(--accent); letter-spacing: .1em; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.profile-bio { font-size: 14px; line-height: 1.9; color: var(--ink); white-space: pre-wrap; margin: 0 0 18px; }
.profile-sub { font-size: 12px; font-weight: 800; color: var(--navy); margin: 0 0 8px; }
.skill-tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 18px; }
.skill-tag { font-size: 12px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); border: 1px solid color-mix(in srgb, var(--accent) 35%, #fff); border-radius: 999px; padding: 4px 12px; }
.contact-list { font-size: 13px; color: var(--ink); line-height: 1.9; }
.contact-list .lab { display: inline-block; width: 4.5em; color: var(--gray); font-weight: 700; font-size: 12px; }

.work-img { width: 100%; flex: 1; min-height: 0; border-radius: 5px; background: #f0f3f6 center/contain no-repeat; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 40px; color: #c2d0da; margin-bottom: 16px; }
.work-title { font-size: 22px; font-weight: 900; color: var(--navy); margin: 0 0 6px; line-height: 1.3; }
.work-concept { font-size: 13.5px; color: #36474f; line-height: 1.7; margin: 0 0 14px; white-space: pre-wrap; }
.work-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; border-top: 1px solid var(--line); padding-top: 12px; }
.work-meta div { font-size: 12px; color: var(--ink); }
.work-meta .lab { display: block; font-size: 10px; font-weight: 800; color: var(--accent); letter-spacing: .06em; }
.pf-empty { text-align: center; color: var(--gray); font-size: 13.5px; padding: 40px 20px; }

/* ---------- btn / toast ---------- */
.btn { font-family: inherit; font-size: 13px; font-weight: 700; padding: 8px 15px; border-radius: 999px; cursor: pointer; border: 1.5px solid var(--line); background: #fff; color: var(--navy); transition: .15s; }
.btn:hover { border-color: var(--teal); color: var(--teal); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--gray); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--navy); color: #fff; font-size: 13.5px; font-weight: 700; padding: 10px 22px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 1000; transition: opacity .3s; max-width: 90vw; text-align: center; }
.toast[hidden] { display: none; }
.site-footer { background: var(--navy); color: #9fc0dd; text-align: center; padding: 24px 20px; font-size: 12.5px; margin-top: 40px; }
.site-footer p { margin: 0; }

/* ---------- page nav ---------- */
.page-nav { display: flex; gap: 12px; align-items: stretch; margin: 40px auto 0; max-width: 980px; }
.pgnav { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 3px; text-decoration: none; background: #fff; border: 1.5px solid #dde5ec; border-radius: 12px; padding: 14px 18px; transition: .15s; box-shadow: 0 2px 12px rgba(0,42,84,.08); }
.pgnav:hover { border-color: #0c8599; transform: translateY(-2px); }
.pgnav.prev { text-align: left; }
.pgnav.top { flex: 0 0 130px; text-align: center; background: #003a73; border-color: #003a73; }
.pgnav.top .pgnav-dir, .pgnav.top .pgnav-name { color: #fff; }
.pgnav.top:hover { background: #002a54; border-color: #002a54; }
.pgnav-dir { font-size: 12px; font-weight: 700; color: #0c8599; }
.pgnav-name { font-size: 14px; font-weight: 900; color: #003a73; }
.pgnav.is-disabled { visibility: hidden; }

@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; }
  .pf-preview-head { position: static; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 25px; }
  .header-inner { flex-direction: column; height: auto; padding: 10px 20px; gap: 4px; }
  .pf-preview-head { top: 0; }
  .page-nav { flex-wrap: wrap; } .pgnav.top { order: -1; flex-basis: 100%; }
  .fld-row { flex-direction: column; gap: 0; }
}

/* ---------- 印刷(PDF保存) ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .site-header, .hero, .lesson, .builder-form, .pf-preview-head, .page-nav, .site-footer, .toast { display: none !important; }
  .container { max-width: none; padding: 0; margin: 0; }
  .builder { display: block; margin: 0; }
  .pf-preview { background: none; box-shadow: none; padding: 0; border-radius: 0; }
  #pf-doc { display: block; padding: 0; gap: 0; }
  .pf-page { box-shadow: none !important; border-radius: 0 !important; margin: 0 !important; aspect-ratio: auto; min-height: 96vh; page-break-after: always; break-after: page; border: none; }
  .pf-page:last-child { page-break-after: auto; break-after: auto; }
  .pf-page.cover::before { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pf-page, .pf-page * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
