:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1c1a;
  --muted: #76726b;
  --line: #e4e1db;
  --accent: #b5532f;
  --accent-ink: #ffffff;
  --ok: #2f7a4f;
  --danger: #b3261e;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.6; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 12px; font-size: 13px; }
input[type=text], input[type=password], input[type=number], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.center-box { max-width: 380px; margin: 12vh auto; padding: 0 16px; }
.center-box h1 { font-size: 20px; margin: 0 0 4px; }
.error { color: var(--danger); font-size: 14px; min-height: 1.4em; margin-top: 8px; }
.badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: var(--line); }
.badge.open { background: #e6efe9; color: var(--ok); }
.badge.submitted { background: #f6e3d9; color: var(--accent); }
.badge.closed { background: #e7e7e7; color: #555; }
.badge.preparing { background: #fdf3d6; color: #8a6a10; }
.badge.reviewing { background: #e3ebfa; color: #1d4ed8; }
.badge.revision { background: #fde7d9; color: #c2410c; font-weight: 700; }
.badge.approved { background: #e6efe9; color: var(--ok); }
.type-tag { font-size: 11px; padding: 1px 8px; border-radius: 4px; background: var(--bg); color: var(--muted); margin-right: 6px; vertical-align: 2px; }
.type-tag.retouch { background: #efe8fb; color: #6d28d9; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 14px;
  z-index: 1000; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
/* スマホでは画面幅いっぱい近くまで広げ、角は少しだけ丸く */
@media (max-width: 640px) {
  .toast {
    left: 12px; right: 12px; bottom: 16px; transform: none;
    border-radius: 12px; padding: 12px 16px; text-align: center; line-height: 1.5;
  }
}

/* ---------- 管理画面 ---------- */
.admin-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.admin-header h1 { font-size: 17px; margin: 0; }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 80px; }
.gallery-list { display: grid; gap: 12px; }
.gallery-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.gallery-row:hover { border-color: var(--text); }
.gallery-row h3 { margin: 0; font-size: 16px; }
.row-meta { font-size: 13px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; }
.share-box { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.share-box code { background: var(--bg); padding: 8px 10px; border-radius: 6px; font-size: 13px; overflow-wrap: anywhere; }
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center;
  color: var(--muted); background: var(--surface); cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); color: var(--accent); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.admin-tile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.admin-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.admin-tile .cap { font-size: 11px; padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tile.sel { outline: 3px solid var(--accent); }
.admin-tile .heart { position: absolute; top: 6px; right: 6px; background: var(--accent); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 8px; }
.admin-tile .heart.liked { background: rgba(255,255,255,.9); color: var(--accent); }
.admin-tile .del { position: absolute; top: 6px; left: 6px; opacity: 0; }
.admin-tile:hover .del { opacity: 1; }
.admin-tile .cmt { font-size: 11px; color: var(--accent); padding: 0 6px 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .admin-header { padding: 12px 16px; } }

/* ---------- 確認ダイアログ ---------- */
.dlg-back {
  position: fixed; inset: 0; z-index: 800; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.dlg { max-width: 400px; width: 100%; }
.dlg h2 { font-size: 18px; margin: 0 0 8px; }
.dlg p { margin: 0 0 20px; white-space: pre-line; color: var(--muted); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- 種類の選択 ---------- */
.type-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-pick label {
  margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px;
}
.type-pick label:has(input:checked) { border-color: var(--accent); background: #fbf3ef; }
.type-pick small { grid-column: 2; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .type-pick { grid-template-columns: 1fr; } }

/* ---------- お知らせ ---------- */
.admin-header { position: relative; }
.hdr-actions { display: flex; gap: 8px; align-items: center; }
.bell-count { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; margin-left: 2px; }
.notif-panel {
  position: absolute; right: 16px; top: calc(100% + 6px); z-index: 700; width: min(420px, calc(100vw - 32px));
  max-height: 70vh; overflow-y: auto; padding: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.15);
}
.notif-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.notif-perm { font-size: 13px; background: #fbf3ef; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; display: grid; gap: 6px; justify-items: start; }
.notif-list { display: grid; gap: 6px; }
.notif-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.notif-item:hover { border-color: var(--text); }
.notif-item.unread { border-left: 4px solid var(--accent); background: #fffaf7; }
.notif-item b { display: block; font-size: 14px; }
.notif-item .when { color: var(--muted); font-size: 11px; }
.notif-item .body { white-space: pre-line; color: var(--muted); max-height: 4.8em; overflow: hidden; }
.notif-channels { font-size: 11px; margin: 10px 0 0; }

/* ---------- レタッチ確認：管理画面 ---------- */
.revise-summary { margin-bottom: 16px; border-left: 4px solid #c2410c; }
.revise-summary h3 { margin: 0 0 8px; font-size: 15px; color: #c2410c; }
.revise-summary ul { margin: 0; padding-left: 18px; font-size: 13px; }
.revise-summary li { margin: 2px 0; }
.revise-summary .done { color: var(--ok); }
.admin-tile.rt { cursor: pointer; }
.admin-tile .rv { position: absolute; top: 6px; right: 6px; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 8px; color: #fff; }
.admin-tile .rv.ok { background: #2f7a4f; }
.admin-tile .rv.revise { background: #c2410c; }
.admin-tile .rv.pending { background: rgba(255,255,255,.92); color: var(--muted); }
.admin-tile.r-revise { outline: 3px solid #c2410c; }
.admin-tile .ver { position: absolute; left: 6px; bottom: 30px; font-size: 10px; font-weight: 700; background: #1d4ed8; color: #fff; border-radius: 4px; padding: 0 5px; }
.admin-tile .cmt.rv-cmt { color: #c2410c; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.pm { position: relative; max-width: 1100px; width: 100%; max-height: 92vh; display: grid; grid-template-columns: 1fr 340px; gap: 16px; padding: 16px; }
.pm-close { position: absolute; right: 8px; top: 4px; border: 0; background: none; font-size: 28px; cursor: pointer; z-index: 2; }
.pm-img { min-height: 0; display: flex; align-items: center; justify-content: center; background: #111; border-radius: 8px; }
.pm-frame { position: relative; }
.pm-frame img { display: block; max-width: 100%; max-height: calc(92vh - 32px); }
.pm-side { overflow-y: auto; min-height: 0; font-size: 14px; }
.pm-side h3 { font-size: 15px; margin: 8px 0 4px; overflow-wrap: anywhere; }
.pm-nav { display: flex; justify-content: space-between; align-items: center; padding-right: 28px; font-size: 13px; }
.pm-feedback { margin: 10px 0; }
.pm-feedback ol { margin: 4px 0; padding-left: 0; list-style: none; }
.pm-feedback li { display: flex; gap: 6px; margin: 4px 0; }
.pm-feedback .quote { background: #fdf1ea; border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; }
.pm-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.pm-history { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.pm-history div { margin: 4px 0; }
.pins { position: absolute; inset: 0; pointer-events: none; }
.pins .pin {
  position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 999px; background: #c2410c; color: #fff; font-size: 12px; font-weight: 700; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.pin-no { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: #c2410c; color: #fff; font-size: 11px; font-weight: 700; }
@media (max-width: 800px) {
  .pm { grid-template-columns: 1fr; overflow-y: auto; }
  .pm-frame img { max-height: 50vh; }
}

/* ---------- セレクトから切り替えたギャラリー ---------- */
.prep-notice { margin-bottom: 16px; padding: 12px 16px; border-radius: 8px; background: #fdf3d6; color: #6b520c; font-size: 14px; }
.selection-card { margin-bottom: 16px; }
.selection-card h3 { margin: 0 0 4px; font-size: 15px; }
.selection-card .sel-progress { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sel-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin: 8px 0; font-size: 13px; }
.sel-item { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.sel-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; flex: none; }
.sel-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-item .st { font-size: 11px; color: var(--muted); }
.sel-item.done { border-color: #b9d6c4; background: #f3f9f5; }
.sel-item.done .st { color: var(--ok); font-weight: 700; }
.sel-item .cm { font-size: 11px; color: var(--accent); }
.selection-card details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.pm-selcomment { font-size: 13px; background: #fbf3ef; border-radius: 8px; padding: 6px 10px; margin: 8px 0; }

/* 案内文を送るのを忘れないよう目立たせる */
.btn.attention {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700;
  padding: 8px 18px; font-size: 14px; animation: attention 1.6s ease-in-out infinite;
}
@keyframes attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(181, 83, 47, .55); }
  50% { box-shadow: 0 0 0 8px rgba(181, 83, 47, 0); }
}

/* ---------- 一覧の絞り込み・検索 ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 32px 0 8px; flex-wrap: wrap; }
.list-head h2 { font-size: 17px; margin: 0; }
.list-head input[type=search] { width: min(320px, 100%); padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.list-tabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.list-tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-size: 14px; }
.list-tabs button span { font-size: 12px; background: var(--line); border-radius: 999px; padding: 0 7px; margin-left: 2px; }
.list-tabs button.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
/* 選んでいるタブの件数は黒丸（赤丸は「対応が必要」だけに使う） */
.list-tabs button.active span { background: var(--text); color: #fff; }
.list-tabs button[data-f=todo] span.has { background: var(--danger); color: #fff; }
.row-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.row-tag { font-size: 11px; padding: 1px 8px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.row-tag.warn { background: #fde7d9; color: #c2410c; font-weight: 700; }
.row-tag.expired { background: #e7e7e7; color: #555; font-weight: 700; }

/* ---------- 詳細画面のお知らせ欄 ---------- */
.alert-box { display: grid; gap: 8px; margin-bottom: 16px; }
.alert { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.alert.warn { background: #fde7d9; color: #8a2d07; }
.alert.info { background: #e6efe9; color: #1e4d33; }
.alert.expired { background: #ececec; color: #444; }
.alert .btn { background: #fff; }

/* ---------- 管理画面の写真一覧のページ分け（pager.js） ---------- */
.admin-main .pager-top { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.admin-main .pager-top button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.admin-main .pager-top button.on { background: var(--text); border-color: var(--text); color: #fff; font-weight: 700; }
.admin-main .pager-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.admin-main .pager-bottom .btn { min-width: 96px; }

/* 写真データを自動削除したギャラリー：画像・アップロード欄・ダウンロードを隠し、記録（ファイル名・状態）だけ表示 */
.purged .admin-tile img, .purged .sel-item img { display: none; }
.purged .dropzone, .purged #uploadStatus, .purged #zipBtn, .purged .selection-card .btn.primary, .purged .admin-tile .del { display: none !important; }
.purged .admin-tile.rt { cursor: default; }

/* ---------- 一覧のゴミ箱ボタン ---------- */
.row-right { display: flex; align-items: center; gap: 10px; flex: none; }
.row-del {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer;
}
.row-del:hover { color: var(--danger); border-color: #f1c9c5; background: #fdf1f0; }

/* ---------- 保存容量 ---------- */
.storage-box { margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.storage-box .bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 6px 0 4px; display: flex; }
.storage-box .bar i { display: block; height: 100%; }
.storage-box .bar .photos { background: var(--accent); }
.storage-box .bar .other { background: #b9b4ac; }
.storage-box.warn { border-color: #f1c9c5; background: #fdf1f0; }
.storage-box.warn b.free { color: var(--danger); }

/* ---------- 写真を選んでまとめて削除 ---------- */
.pick-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.pick-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.picking .admin-tile { cursor: pointer; }
.picking .admin-tile .del { display: none; }
.admin-tile .pick-mark {
  position: absolute; left: 6px; top: 6px; width: 24px; height: 24px; border-radius: 999px; z-index: 2;
  border: 2px solid #fff; background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.admin-tile.picked { outline: 3px solid var(--danger); }
.admin-tile.picked .pick-mark { background: var(--danger); }
.admin-tile.picked img { opacity: .7; }

/* ---------- ギャラリー情報の編集 ---------- */
.edit-form { max-width: 460px; }
.edit-form label { margin-top: 10px; }
.edit-note { font-size: 12px; margin-top: 4px; }
