:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #cbd5e1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --text: #0f172a;
  --muted: #475569;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; padding: 16px; overflow-wrap: anywhere; }
.container { max-width: 1320px; margin: 0 auto; }
a { color: var(--primary-dark); }
h1 { font-size: 1.55rem; line-height: 1.4; letter-spacing: -0.3px; }
h2 { font-size: 1.1rem; line-height: 1.5; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
p, ul, ol, table { margin-bottom: 10px; }
ul, ol { padding-left: 1.4em; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 0.85rem; }

/* サイトのヘッダー */
.site-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.logo { font-size: 1.2rem; font-weight: 800; color: var(--text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.9rem; font-weight: 600; }
.site-nav a { text-decoration: none; }

/* ヒーロー */
.hero { margin-bottom: 16px; }
.hero-sub { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin: 4px 0 10px; }
.hero-points { list-style: none; padding: 0; display: grid; gap: 4px; font-size: 0.92rem; }
.hero-points li { padding-left: 1.4em; position: relative; }
.hero-points li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }

/* カード・ボタン */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.btn, .chip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); background: #f1f5f9; color: var(--text); font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover:not(:disabled), .chip:hover:not(:disabled) { background: var(--primary-light); border-color: #bfdbfe; }
.btn:disabled, .chip:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.danger { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: 0.82rem; }
.btn.big { min-height: 48px; padding: 8px 22px; font-size: 1rem; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-row, .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.msg { padding: 8px 10px; border-radius: 8px; font-size: 0.88rem; margin: 8px 0; }
.msg.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.msg.info { background: var(--primary-light); border: 1px solid #bfdbfe; }
.warn-box, .hint { background: var(--warn-bg); border-left: 4px solid var(--warn-line); padding: 8px 10px; border-radius: 6px; font-size: 0.86rem; margin: 10px 0; }
.field { display: block; margin: 10px 0; font-size: 0.88rem; font-weight: 700; }
.field select { display: block; margin-top: 4px; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.field-row .field { flex: 1 1 150px; }
.val { color: var(--primary-dark); font-weight: 800; }
select { width: 100%; min-height: 40px; background: #fff; border: 1px solid var(--line); color: var(--text); padding: 6px 10px; border-radius: 8px; font: inherit; font-size: 0.9rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); height: 28px; }

/* 編集画面 */
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .tool-grid { grid-template-columns: minmax(0, 1fr); } }
.stage-card { position: sticky; top: 8px; }
@media (max-width: 1000px) { .stage-card { position: static; } }
.panel { display: grid; gap: 12px; }
.panel h2 { font-size: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.btn-undo { min-height: 48px; min-width: 124px; font-size: 1rem; background: #fff; border-width: 2px; }
.seg { display: flex; gap: 4px; }
.zoom { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.zoom .chip { min-width: 40px; padding: 4px 8px; }
.zoom-label { font-size: 0.8rem; color: var(--muted); min-width: 3.5em; text-align: right; }
.stage { position: relative; height: min(68vh, 640px); min-height: 300px; background: #e2e8f0 repeating-conic-gradient(#e2e8f0 0 25%, #f1f5f9 0 50%) 0 0 / 20px 20px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.stage.has-image { touch-action: none; cursor: crosshair; }
.stage.has-image[data-tool="pan"] { cursor: grab; }
.stage.has-image[data-tool="brush"] { cursor: none; }
.stage.dragging { outline: 3px dashed var(--primary); outline-offset: -6px; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px; color: var(--muted); }
.stage-empty-h { font-weight: 700; color: var(--text); }
.stage canvas, .face-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage canvas { box-shadow: 0 2px 10px rgba(0,0,0,0.15); }
/* 線の太さは画面上で一定にする（--k = 1 ÷ 表示倍率。CSS の transform で縮小するため non-scaling-stroke は使えない） */
.face-layer rect { fill: rgba(37, 99, 235, 0.2); stroke: #2563eb; stroke-width: calc(3px * var(--k, 1)); cursor: pointer; }
.face-layer rect.off { fill: rgba(255, 255, 255, 0.08); stroke: #f8fafc; stroke-dasharray: calc(8px * var(--k, 1)) calc(5px * var(--k, 1)); }
.sel { position: absolute; border: 2px dashed var(--primary); background: rgba(37, 99, 235, 0.15); pointer-events: none; }
.brush-cursor { position: absolute; left: 0; top: 0; border: 2px solid #fff; outline: 1px solid #0f172a; border-radius: 50%; pointer-events: none; }
.stage-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; font-size: 0.85rem; }
[hidden] { display: none !important; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px dashed var(--line); border-radius: 10px; padding: 14px 10px; text-align: center; cursor: pointer; background: #fafafa; }
.drop:hover, .drop.dragging { border-color: var(--primary); background: var(--primary-light); }
.drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-label { font-weight: 700; color: var(--primary-dark); }
.drop-file { font-size: 0.82rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop.loaded { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.drop-wide { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; }
.offline { font-size: 0.82rem; color: var(--muted); margin: 8px 0 0; }
.offline.ok { color: var(--ok); font-weight: 700; }

/* この写真から分かること */
.exif-summary { font-weight: 700; background: var(--warn-bg); border-left: 4px solid var(--warn-line); padding: 8px 10px; border-radius: 6px; }
.exif-none { color: var(--ok); font-weight: 700; }
.exif-nogps { color: var(--ok); font-size: 0.88rem; }
.exif-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; font-size: 0.88rem; }
.exif-list dt { color: var(--muted); font-weight: 700; }
.exif-list dd.warn { font-weight: 700; }
.map-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-weight: 400; }
.map-row .note { font-size: 0.78rem; }
@media (max-width: 420px) { .exif-list { grid-template-columns: 1fr; } .exif-list dd { margin-bottom: 6px; } }

/* 一括モード */
.batch { margin-top: 16px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; background: #fff; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
thead th { background: #f1f5f9; white-space: nowrap; }
table.small { font-size: 0.82rem; }
.batch-table td.name { max-width: 16em; word-break: break-all; }
.batch-table tr.has-gps { background: var(--danger-bg); }
.batch-table .gps-yes { color: var(--danger); font-weight: 800; }
.batch-table .gps-no { color: var(--ok); }
.batch-table .err { color: var(--danger); }

/* 説明・静的ページ */
.explain { margin-top: 28px; max-width: 900px; }
.explain h2, .page h2 { margin-top: 28px; padding-left: 10px; border-left: 4px solid var(--primary); }
.steps li { margin-bottom: 6px; }
.notes li { margin-bottom: 4px; font-size: 0.92rem; }
.link-list li { margin-bottom: 4px; }
.page { max-width: 820px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.page .lead { font-size: 1rem; margin-top: 10px; }
.cta { margin: 16px 0; }
.pending { background: var(--primary-light); border: 1px solid #bfdbfe; padding: 8px 12px; border-radius: 8px; font-size: 0.9rem; }
.tip-box { background: var(--ok-bg); border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 14px; }
.tip-h { font-weight: 800; margin-bottom: 4px; }
.checked-os { display: inline-flex; gap: 8px; flex-wrap: wrap; font-size: 0.88rem; background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; margin-top: 10px; }
.checked-os span { font-weight: 700; }
.crumbs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.82rem; margin-bottom: 10px; }
.crumbs li + li::before { content: "›"; margin-right: 4px; color: var(--muted); }

/* フッター（サイト内） */
.site-footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; font-size: 0.88rem; }
.site-footer h2 { font-size: 0.95rem; margin-bottom: 6px; }
.site-footer ul { padding-left: 1.1em; }

/* 入口ページのボタンから開いたとき（/?mode=…） */
.mode-banner { background: var(--primary-light); border: 1px solid #bfdbfe; border-left: 4px solid var(--primary); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.92rem; font-weight: 600; }
.card.mode-focus { outline: 3px solid var(--primary); outline-offset: 2px; }

/* 入口ページ（用途別・機種別・アプリ別・解説） */
.summary { background: var(--ok-bg); border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.summary-h { font-weight: 800; margin-bottom: 4px; }
.faq h3 { font-size: 1rem; margin: 16px 0 4px; }
.faq h3::before { content: "Q. "; color: var(--primary-dark); }
.checked { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 0.9rem; }
.checked dt { font-weight: 700; color: var(--muted); }
.checked ul { padding-left: 1.1em; margin: 0; }
@media (max-width: 420px) { .checked { grid-template-columns: 1fr; } }
.point { background: var(--warn-bg); border-left: 4px solid var(--warn-line); padding: 8px 12px; border-radius: 6px; margin: 10px 0; }
.shot { border: 2px dashed var(--line); border-radius: 8px; padding: 14px; margin: 10px 0; color: var(--muted); font-size: 0.88rem; background: #f8fafc; }
.shot span { display: block; font-weight: 700; color: var(--text); }
.shot-img { margin: 12px 0; }
.shot-img img { display: block; max-width: min(100%, 420px); height: auto; border: 1px solid var(--line); border-radius: 10px; }
.shot-img figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
