/* ============ 現場小黒板 アプリ 基本スタイル ============ */
:root {
  --header: #0f8a58;
  --tile-shoot: #ba7517;   /* 撮影：アンバー */
  --tile-photos: #0f6e56;  /* 写真一覧：ティール */
  --tile-board: #3b6d11;   /* 黒板設定：グリーン */
  --tile-settings: #5f5e5a;/* 設定：グレー */
  --ink: #141414;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", Meiryo, sans-serif;
  background: #eef5f0;
  color: var(--ink);
}

/* ---- ヘッダー ---- */
.app-header {
  background: var(--header);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 600;
}
.app-header .title { flex: 1; }
.app-header .icon { font-size: 22px; line-height: 1; }
/* ヘッダー右上の統一メニュー（押しやすい当たり判定） */
.hdr-menu {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  width: 44px;
  height: 44px;
  margin: -8px -8px -8px 0;
  border-radius: 10px;
  cursor: pointer;
}
.hdr-menu:active { background: rgba(255, 255, 255, 0.18); }
/* メニュー内の項目（アイコン＋ラベルを横並び・大きめタップ） */
.sheet-btn.row { display: flex; align-items: center; gap: 12px; text-align: left; }
.sheet-btn .mi-ico { font-size: 22px; width: 28px; text-align: center; }

/* ---- ホームのタイル ---- */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
}
.tile {
  border: none;
  border-radius: 14px;
  color: #fff;
  padding: 26px 10px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 17px;
  font-weight: 600;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.tile:active { transform: scale(0.97); filter: brightness(0.93); }
.tile .emoji { font-size: 44px; line-height: 1; }
.tile-shoot { background: var(--tile-shoot); }
.tile-photos { background: var(--tile-photos); }
.tile-board { background: var(--tile-board); }
.tile-settings { background: var(--tile-settings); }

.home-note {
  text-align: center;
  color: #888780;
  font-size: 12px;
  padding: 8px 16px 24px;
}

/* ===== 新ホーム（撮影ヒーロー＋現場フォルダ） ===== */
.home2 { padding: 14px; }
.hero-shoot {
  width: 100%;
  border: none;
  background: var(--tile-shoot);
  color: #fff;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.hero-shoot:active { filter: brightness(0.94); }
.hero-shoot .hs-ico { font-size: 46px; line-height: 1; }
.hero-shoot .hs-title { font-size: 21px; font-weight: 600; }
.hero-shoot .hs-sub { font-size: 12px; opacity: 0.92; }

/* 写真に黒板をのせる（カメラ不要・ホームの副ボタン） */
.hero-import {
  margin-top: 10px;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #e2e0d8;
  border-radius: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--ink);
}
.hero-import:active { filter: brightness(0.96); }
.hero-import .hi-ico { font-size: 26px; line-height: 1; }
.hero-import .hi-text { display: flex; flex-direction: column; }
.hero-import .hi-text b { font-size: 15px; }
.hero-import .hi-text span { font-size: 11px; color: #888780; }

.section-label {
  font-size: 13px;
  color: #5f5e5a;
  font-weight: 600;
  margin: 20px 2px 10px;
}
.sites-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.site-card {
  background: #fff;
  border: 0.5px solid #e2e0d8;
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  /* 長押し（並べ替え）でフォルダ名の文字が範囲選択されないようにする（名前の編集はメニューから） */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* touch-action は既定(auto)＝軽くなぞればスクロールできる。
     長押し→ドラッグの並べ替えは JS が（ドラッグ中だけ）preventDefault してスクロールを止める。
     ※写真一覧(.photo-card)と同じ作り。 */
}
.site-card .sc-name { font-size: 14px; font-weight: 500; }
.site-card .sc-count { font-size: 11px; color: #888780; }
/* フォルダ並べ替え：ドラッグ中の浮かぶ複製と、元位置のプレースホルダ */
.sc-drag-clone {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  box-sizing: border-box;
  margin: 0;
  opacity: 0.95;
  transform: scale(1.04);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
}
.site-card.sc-placeholder { opacity: 0.35; touch-action: none; }
/* バージョン表示（更新が反映されたか目視確認用） */
.app-ver { text-align: center; font-size: 12px; color: #b6b4ac; padding: 14px 0 6px; }
.app-ver-inline { font-size: 12px; font-weight: 400; opacity: 0.85; }
.site-new {
  border: 1.5px dashed #c9a35a;
  border-radius: 12px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #9a6a12;
  cursor: pointer;
  background: transparent;
}
.empty-sites {
  text-align: center;
  color: #888780;
  font-size: 13px;
  padding: 18px;
  border: 1px dashed #d3d1c7;
  border-radius: 12px;
}
.sc-menu {
  margin-left: auto;
  border: none;
  background: transparent;
  color: #888780;
  font-size: 20px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

/* アクションシート（フォルダのメニュー） */
.sheet-ov {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1100; /* 選択バー(80)より手前に出す＝入力欄/フォルダ選択を確実に操作できる */
}
.sheet {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 8px;
}
.sheet-title {
  text-align: center;
  font-size: 13px;
  color: #888780;
  padding: 12px 8px 8px;
}
.sheet-btn {
  width: 100%;
  border: none;
  background: #eef5f0;
  border-radius: 10px;
  padding: 14px;
  margin-top: 8px;
  font-size: 16px;
  cursor: pointer;
}
.sheet-btn.danger { color: #a32d2d; font-weight: 600; }
/* 現場の共有ダイアログ */
.share-note { font-size: 13px; color: #5f5e5a; line-height: 1.6; padding: 2px 8px 10px; text-align: center; }
.qr-img { display: block; width: 220px; max-width: 70%; height: auto; margin: 4px auto 12px; image-rendering: pixelated; border: 8px solid #fff; border-radius: 8px; background: #fff; }
.share-input { width: 100%; box-sizing: border-box; border: 1px solid #cfcdc4; border-radius: 10px; padding: 12px; font-size: 14px; resize: vertical; margin-bottom: 2px; }
.install-card { background: #faf9f5; border: 1px solid #e2e0d8; border-radius: 10px; padding: 12px; margin-top: 8px; font-size: 14px; line-height: 1.7; color: #2a2a26; }
.date-edit { display: flex; gap: 8px; justify-content: center; padding: 12px 6px 6px; }
.date-edit label { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: #6b6a63; }
.date-edit input { width: 74px; padding: 10px; font-size: 18px; text-align: center; border: 1px solid #cfcdc4; border-radius: 8px; }
.home-mini-row { display: flex; gap: 10px; margin-top: 18px; }
.home-mini {
  flex: 1;
  background: #fff;
  border: 0.5px solid #e2e0d8;
  border-radius: 10px;
  padding: 11px;
  text-align: center;
  font-size: 13px;
  color: #5f5e5a;
  text-decoration: none;
  display: block;
}
.home-mini .hm-ico { font-size: 20px; display: block; margin-bottom: 3px; }

/* ===== 「最新版に更新しました」バー ===== */
.gk-upbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 200;
  background: #1f5d3a;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}
.gk-upbar span { flex: 1; }
.gk-upbar button {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
}

/* ===== 使い方 ===== */
.help-wrap { padding: 14px; max-width: 600px; margin: 0 auto; }
.help-lead {
  background: #eaf2fb;
  border: 0.5px solid #cfe0f2;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #234;
  margin-bottom: 12px;
}
.help-sec {
  background: #fff;
  border: 0.5px solid #e2e0d8;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.help-sec.hl { background: #fbf6e9; border-color: #ecdcb4; }
.help-sec h2 { font-size: 16px; margin: 0 0 8px; }
.help-sec p { font-size: 14px; line-height: 1.7; color: #3a3a36; margin: 0 0 6px; }
.help-sec p:last-child { margin-bottom: 0; }
.help-sec ol, .help-sec ul { margin: 4px 0 0; padding-left: 1.3em; }
.help-sec li { font-size: 14px; line-height: 1.8; color: #3a3a36; }
.help-sec b { color: #1b1b18; }
.help-note { font-size: 13px !important; color: #888780 !important; }
.help-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 4px;
  padding: 14px;
  background: #fff;
  border: 1px solid #c9c7bd;
  border-radius: 10px;
  color: #0f8a58;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
}
.help-pdf:active { background: #eef4fb; }
.help-foot { text-align: center; color: #b6b4ac; font-size: 12px; padding: 8px 0 20px; }

/* ===== 定型一覧 ===== */
.preset-intro {
  padding: 12px 14px;
  background: #f6f4ec;
  border-bottom: 1px solid #e2e0d8;
  font-size: 13px;
  color: #6b6a63;
  line-height: 1.6;
}
.preset-intro b { color: #2a2a26; }
.preset-list { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; max-width: 560px; margin: 0 auto; }
.preset-item {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0.5px solid #e2e0d8;
  border-radius: 12px;
  padding: 13px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.preset-item:active { background: #f6f4ee; }
.pi-head { display: flex; align-items: center; gap: 8px; }
.pi-name { font-size: 16px; font-weight: 700; flex: 1; }
.pi-chip { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; flex: 0 0 auto; }
.pi-chip.white { background: #fff; color: #333; border: 1px solid #c9c7bd; }
.pi-chip.green { background: #1f5d3a; color: #fff; }
.pi-tpl { font-size: 12px; color: #888780; margin-top: 2px; }
.pi-body { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.pi-row { display: flex; gap: 8px; font-size: 14px; }
.pi-lab { color: #888780; flex: 0 0 auto; min-width: 4.5em; }
.pi-val { color: #2a2a26; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-more { font-size: 12px; color: #a8a6a0; margin-top: 2px; }
.pi-empty { margin-top: 8px; font-size: 13px; color: #a8a6a0; }
.tpl-cat { font-size: 13px; font-weight: 700; color: #5f5e5a; margin: 14px 2px 2px; }
.tpl-cat:first-child { margin-top: 2px; }

/* ===== 設定画面 ===== */
.set-wrap { padding: 14px; max-width: 560px; margin: 0 auto; }
.set-group-label { font-size: 12px; color: #888780; margin: 18px 4px 6px; font-weight: 600; }
.set-group-label:first-child { margin-top: 6px; }
.set-card { background: #fff; border: 0.5px solid #e2e0d8; border-radius: 12px; overflow: hidden; }
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 14px;
  border-top: 0.5px solid #eceae2;
}
.set-row:first-child { border-top: none; }
.set-row .set-text { flex: 1; }
.set-row .set-text b { display: block; font-size: 15px; font-weight: 600; }
.set-row .set-text span { display: block; font-size: 12px; color: #888780; margin-top: 2px; }
.set-row.tap { cursor: pointer; }
.set-row.tap:active { background: #f6f4ee; }
.set-row .set-val { font-size: 14px; color: #5f5e5a; }
.set-select {
  flex: 0 0 auto;
  height: 38px;
  border: 1px solid #c9c7bd;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 15px;
  background: #fff;
}
.set-row.danger b { color: #a32d2d; }

/* トグルスイッチ */
.switch { position: relative; width: 50px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #cfcdc4; border-radius: 30px; transition: background 0.15s;
}
.switch .track::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px;
  background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .track { background: #2a9d5c; }
.switch input:checked + .track::before { transform: translateX(20px); }

/* ===== 写真一覧 ===== */
/* この現場で撮影する＝一番上の目立つ横帯 */
.photos-shoot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 14px 2px;
  padding: 16px;
  background: #ba7517;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(186, 117, 23, 0.35);
}
.photos-shoot:active { background: #a5670f; }
/* 写真を選択（複数まとめて保存/削除）ツールバー */
.photos-toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 2px 14px 0; }
.select-btn {
  background: #fff;
  border: 1px solid #c9c7bd;
  color: #5f5e5a;
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
.select-btn.on { background: #0f8a58; color: #fff; border-color: #0f8a58; font-weight: 600; }
/* 選択モード中の2ボタンは幅も揃えて「同じ大きさ」に見せる */
.select-btn.on, .selectall-top { min-width: 108px; text-align: center; box-sizing: border-box; }
/* 「選択をやめる」の左に置く全選択：同じ大きさで色を変える（緑）＝わかりやすく */
.selectall-top { background: #1f7a4d; border-color: #1f7a4d; color: #fff; font-weight: 600; }
.selectall-top:active { background: #195f3c; }

.photos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
/* 選択モード中：⋮を隠し、チェックを出す */
.photos-grid.selecting .pc-menu { display: none; }
.pc-check {
  position: absolute;
  top: 8px; left: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 2px solid #b9b7ad;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: transparent;
}
.photos-grid.selecting .pc-check { display: flex; }
.photo-card.sel { outline: 3px solid #0f8a58; }
.photo-card.sel .pc-check { background: #0f8a58; border-color: #0f8a58; color: #fff; }

/* 選択中の操作バー（画面下に固定） */
.select-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 80;
  background: #fff;
  border-top: 1px solid #e2e0d8;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -3px 12px rgba(0,0,0,0.12);
}
.sb-count { font-size: 13px; color: #5f5e5a; text-align: center; margin-bottom: 8px; }
.sb-top { display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.sb-top .sb-count { margin-bottom: 0; }
.sb-all {
  background: #ecf6f0; color: #0f8a58; border: 1px solid #cfe4d8;
  border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.sb-share { background: #0f8a58; color: #fff; }
.sb-move, .sb-date { background: #ecf6f0; color: #1f5486; }
.sb-actions2 { margin-top: 8px; }
.sb-actions { display: flex; gap: 8px; }
.sb-actions button { flex: 1; border: none; border-radius: 10px; padding: 13px 6px; font-size: 15px; font-weight: 600; cursor: pointer; }
.sb-save { background: #ba7517; color: #fff; }
.sb-del { background: #fff; color: #a32d2d; border: 1px solid #e0b9b9 !important; }
.sb-cancel { background: #eef5f0; color: #5f5e5a; }
.sb-actions button:disabled { opacity: 0.45; }
.photo-card {
  position: relative;
  background: #ddebe3;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.photo-card img { width: 100%; display: block; border-radius: 4px; pointer-events: none; }
.photo-card.pc-placeholder { opacity: 0.32; touch-action: none; }
.pc-drag-clone {
  position: fixed;
  margin: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.95;
  transform: scale(1.05);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  background: #ddebe3;
  border-radius: 8px;
  padding: 6px;
  box-sizing: border-box;
}
.pc-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-zoom {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 50;
  overflow: hidden;
  touch-action: none; /* 横スワイプをpointerイベントで確実に拾う */
}
.zoom-track { display: flex; height: 100%; will-change: transform; }
.zoom-track.anim { transition: transform 0.28s ease-out; } /* 離した後スッと吸い付く */
.zoom-slide {
  flex: 0 0 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.zoom-slide img { max-width: 100%; max-height: 90%; border-radius: 4px; -webkit-user-drag: none; user-select: none; }
.zoom-count {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 12px;
  pointer-events: none;
}

/* ===== トースト ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1d9e75;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
