:root {
  --bg: #f4f6f5; --card: #fff; --ink: #222; --sub: #667; --line: #dde3e0; --brand: #2f9e77;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17191a; --card: #222527; --ink: #eee; --sub: #9aa; --line: #383d3f; --brand: #3fb68b; }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Noto Sans JP', 'Noto Sans CJK JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
}
header { padding: 14px 16px 0; max-width: 1100px; margin: 0 auto; }
h1 { margin: 0 0 10px; font-size: 20px; }
h1 small { font-size: 12px; color: var(--sub); font-weight: 400; margin-left: 8px; }
h2 { font-size: 13px; margin: 18px 0 8px; color: var(--sub); font-weight: 700; }
h2:first-child { margin-top: 0; }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; }
.steps li { flex: 1; text-align: center; padding: 8px 4px; font-size: 13px; background: var(--line); color: var(--sub); border-radius: 8px; }
.steps li.on { background: var(--brand); color: #fff; font-weight: 700; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.mode { display: block; cursor: pointer; }
.mode input { position: absolute; opacity: 0; }
.mode span { display: block; padding: 12px; border: 2px solid var(--line); border-radius: 10px; }
.mode b { display: block; font-size: 17px; }
.mode em { font-style: normal; font-size: 11px; color: var(--sub); }
.mode input:checked + span { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.mode input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.row { display: flex; gap: 8px; }
input[type=text], select, textarea {
  width: 100%; padding: 10px; font: inherit; font-size: 16px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.5; }
input[type=color] { width: 100%; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
label { display: block; font-size: 13px; color: var(--sub); margin-bottom: 10px; }
label > input, label > select { margin-top: 4px; }
button {
  font: inherit; font-size: 15px; padding: 10px 16px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 700; white-space: nowrap;
}
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
button:disabled { opacity: .4; cursor: not-allowed; }
.hint { font-size: 12px; color: var(--sub); margin: 8px 0 0; min-height: 1em; }
.payload { display: block; padding: 10px; background: var(--bg); border-radius: 8px; word-break: break-all; font-size: 13px; }
.qrcard { text-align: center; }
#qrPreview { width: min(280px, 100%); height: auto; border: 1px solid var(--line); background: #fff; }
.nav { display: flex; justify-content: space-between; gap: 8px; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 12px; align-items: start; }
.colors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 50%; }
.actions { display: grid; gap: 10px; }
.previewbox { background: #888; display: flex; justify-content: center; }
.a4 { width: 100%; max-width: 520px; aspect-ratio: 210 / 297; background: #fff; box-shadow: 0 2px 12px #0005; }
.a4 svg { width: 100%; height: 100%; display: block; }
#printArea { display: none; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }
@media print {
  @page { size: A4; margin: 0; }
  body > *:not(#printArea) { display: none !important; }
  body { background: #fff; }
  #printArea { display: block; }
  #printArea img { width: 210mm; height: 297mm; display: block; }
}

/* テンプレート選択（ボタン式） */
.tplMenu { display: grid; gap: 6px; }
.tplMenu button { text-align: left; background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 400; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: normal; }
.tplMenu button small { color: var(--sub); font-size: 11px; font-weight: 400; }
.tplMenu button.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); font-weight: 700; }
/* 編集元バナー・チェック */
.banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; padding: 8px 12px; margin-bottom: 12px; border-radius: 10px; background: color-mix(in srgb, var(--brand) 14%, transparent); border: 1px solid var(--brand); }
.banner[hidden] { display: none; }
label.chk { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; }
label.chk input { margin-top: 3px; }
/* ヘッダー・履歴・コーチマーク */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tools { display: flex; gap: 6px; }
button.sm { padding: 6px 10px; font-size: 13px; }
.hbtns button { flex: 1 1 auto; }
.hist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.hcard { display: flex; min-width: 0; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.thumb { width: 96px; flex: none; box-shadow: 0 1px 4px #0004; }
.hinfo { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.hinfo b { font-size: 15px; overflow-wrap: anywhere; }
.hinfo span { font-size: 13px; }
.hinfo small { font-size: 11px; color: var(--sub); overflow-wrap: anywhere; }
.hbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
#coach { position: fixed; inset: 0; z-index: 1000; }
#coach[hidden] { display: none; }
#coach .spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .62); outline: 2px solid #fff; pointer-events: none; }
#coach .tip { position: fixed; background: var(--card); color: var(--ink); border-radius: 12px; padding: 14px; box-shadow: 0 6px 24px #0007; }
#coach .tipHead { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#coach .tipHead span { font-size: 12px; color: var(--sub); }
#coach p { margin: 0 0 12px; font-size: 14px; line-height: 1.6; }
.tipBtns { display: flex; justify-content: flex-end; gap: 8px; }
[hidden] { display: none !important; }
.drop { border: 2px dashed var(--line); border-radius: 10px; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; color: var(--sub); font-size: 13px; line-height: 1.6; background-size: cover; background-position: center; overflow: hidden; }
.drop small { font-size: 11px; }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--brand); color: var(--ink); outline: none; background-color: color-mix(in srgb, var(--brand) 10%, transparent); }
.drop.has { color: transparent; border-style: solid; }
.drop.has.over { color: #fff; text-shadow: 0 1px 3px #000; }
