:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d1f24;
  --muted: #5d6270;
  --line: #d9d5cc;
  --accent: #b5302a;   /* hanko red */
  --accent-ink: #ffffff;
  --soft: #f8e9e7;
  --focus: #2457c5;
  --ok: #2c7a4b;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif; }
a { color: var(--focus); }
code { background: #eee; padding: 0 .3em; border-radius: 3px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand .jp { color: var(--accent); font-weight: 600; font-size: 14px; margin-left: 4px; }
.top nav { display: flex; gap: 16px; flex-wrap: wrap; }
.top nav a { color: var(--ink); text-decoration: none; font-size: 14px; }
.top nav a:hover { text-decoration: underline; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #e6e3dc; color: var(--muted); }
.badge.on { background: var(--ok); color: #fff; }
.privacy-bar { background: #eef5ef; color: #1f4d31; font-size: 13px; padding: 7px 16px; border-bottom: 1px solid #d4e6d8; }

.app { display: grid; grid-template-columns: minmax(340px, 520px) 1fr; gap: 16px; padding: 16px; align-items: start; max-width: 1500px; margin: 0 auto; }
.form { min-width: 0; }
.preview { position: sticky; top: 8px; min-width: 0; background: #e7e4dd; border-radius: 10px; padding: 10px; max-height: calc(100vh - 16px); display: flex; flex-direction: column; }
.pv-bar { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.pv-scroll { overflow: auto; flex: 1; min-height: 300px; }
.pv-scale { position: relative; margin: 0 auto; }
.sheets { transform-origin: top left; position: absolute; left: 0; top: 0; }
.sheets .sheet, .sheets .cv { margin-bottom: 8mm; box-shadow: 0 1px 6px rgba(0,0,0,.18); }
.sheets .too-long { background: #fff1b8; }
.warn { background: #fff4d6; border: 1px solid #ecd28a; color: #5a4300; font-size: 13px; padding: 8px 10px; border-radius: 6px; margin-bottom: 8px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
button, .btn, .btnlink { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 12px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 36px; }
button:hover, .btn:hover { border-color: #b9b3a6; }
button.primary, .btnlink.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.07); }
button.ghost { background: transparent; }
button.small { font-size: 13px; padding: 4px 9px; min-height: 30px; }
button.icon { padding: 2px 8px; min-height: 28px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; padding: 0 14px; }
.card > summary { font-weight: 700; padding: 12px 0; cursor: pointer; list-style-position: inside; }
.card[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.card > :last-child { margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid > label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; min-width: 0; }
.grid .span2 { grid-column: 1 / -1; }
.grid small, .photo-ctl small { font-weight: 400; color: var(--muted); font-size: 12px; line-height: 1.45; }
input, select, textarea { font: inherit; font-size: 15px; font-weight: 400; color: var(--ink); background: #fff; border: 1px solid #c9c4b9; border-radius: 6px; padding: 7px 9px; width: 100%; min-width: 0; }
textarea { resize: vertical; font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif; }
.ymd { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px; }
.ymd2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 6px; }
.row { display: flex; gap: 6px; }
.row input { flex: 1; }
.row button { white-space: nowrap; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #c9c4b9; border-radius: 6px; padding: 6px 10px; font-weight: 400; cursor: pointer; }
.seg input, .chk input { width: auto; }
.chk { flex-direction: row !important; align-items: center; font-weight: 400 !important; grid-column: 1 / -1; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.fine { font-size: 12px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 10px; background: #fcfbf9; }
.item-bar { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.item-bar .sp { flex: 1; }
.add { width: 100%; justify-content: center; border-style: dashed; }
details.sub { margin-top: 10px; }
details.sub > summary { cursor: pointer; font-size: 13px; color: var(--focus); margin-bottom: 8px; }
.chips details { margin-top: 10px; font-size: 13px; }
.chips summary { cursor: pointer; color: var(--focus); }
.cg { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.cg b { width: 100%; font-size: 12px; color: var(--muted); }
.chip { font-size: 13px; padding: 2px 9px; min-height: 28px; border-radius: 14px; background: #f3f1ec; }
.pro-tag { font-size: 11px; background: var(--soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; font-weight: 700; vertical-align: middle; }

.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; border-color: transparent; }
.tabs button.on { background: var(--panel); border-color: var(--line); font-weight: 700; }

.photo-tool { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.crop { position: relative; width: 150px; height: 200px; border: 1px solid #c9c4b9; border-radius: 4px; overflow: hidden; background: #eee; flex: none; }
.crop canvas { width: 150px; height: 200px; display: block; touch-action: none; cursor: grab; }
.crop-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.photo-ctl { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 180px; font-size: 13px; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; max-width: 480px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(20, 20, 20, .45); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog ol { padding-left: 20px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.wm-note { background: var(--soft); padding: 8px 10px; border-radius: 6px; font-size: 13px; }
.foot { text-align: center; font-size: 12px; color: var(--muted); padding: 10px 16px 30px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; padding: 12px 16px; }
  .preview { position: static; max-height: none; }
  .pv-scroll { max-height: 80vh; }
}
@media (max-width: 420px) {
  .grid { grid-template-columns: 1fr; }
}

/* ---------- print: only the paper ---------- */
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(main) { display: none !important; }
  .app { display: block; padding: 0; margin: 0; max-width: none; }
  .form, .pv-bar, .warn { display: none !important; }
  .preview { position: static; background: none; padding: 0; max-height: none; display: block; border-radius: 0; }
  .pv-scroll { overflow: visible; max-height: none; }
  .pv-scale { width: auto !important; height: auto !important; }
  .sheets { position: static; transform: none !important; }
  .sheets .sheet { margin: 0; box-shadow: none; break-after: page; page-break-after: always; }
  .sheets .sheet:last-child { break-after: auto; page-break-after: auto; }
  .sheets .too-long { background: none; }
  body.print-cv .sheets .cv { width: auto; min-height: 0; padding: 0; margin: 0; box-shadow: none; overflow: visible; }
  body.print-cv .cv .wm { position: fixed; }
}
