:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e0e4ea;
  --text: #263238;
  --muted: #78909c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.site-header {
  position: relative;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.site-header h1 { margin: 0; font-size: 1.4rem; }
/* ヘッダ中央のアクセスカウンター（赤太字・通常より少し大きめ） */
.site-header__counter {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #e53935;
  font-weight: 700;
  font-size: 1.2rem;         /* 通常文字（1rem）より少し大きめ */
  letter-spacing: .04em;
  background: rgba(255, 255, 255, .92);
  padding: 4px 14px; border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  white-space: nowrap;
  pointer-events: none;
}
@media (max-width: 640px) {
  .site-header__counter { position: static; transform: none; margin: 0 auto; }
}
.site-header__user { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.site-header__name { font-size: .9rem; opacity: .95; }

/* ---- ログイン画面 ---- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e3f2fd, #f4f6f9);
}
.login-card { width: 360px; max-width: 92vw; }
.login-title { margin: 0 0 4px; font-size: 1.3rem; color: var(--primary-dark); }
.login-sub { margin: 0 0 18px; color: var(--muted); font-size: .9rem; }
.login-error {
  background: #ffebee; color: #c62828; border: 1px solid #ef9a9a;
  padding: 8px 12px; border-radius: 8px; font-size: .88rem; margin: 0 0 14px;
}

.container { max-width: 1080px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .05);
}

h2 { font-size: 1.15rem; margin: 0 0 12px; }

/* ---- トップエリア ---- */
.top-area { margin-bottom: 28px; }
.top-area__header {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 2px solid var(--primary); padding-bottom: 8px; margin-bottom: 16px;
}
.top-area__header h2 { margin: 0; }

.info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 16px;
  margin: 0;
}
.info-grid dt { color: var(--muted); font-weight: 600; }
.info-grid dd { margin: 0; }
.name-list { margin: 0; padding-left: 18px; }
/* 編集不可のメッセージ欄：1行代表表示（はみ出しは省略） */
.msg-summary {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.updated { color: var(--muted); font-size: .85rem; margin: 12px 0 0; text-align: right; }

/* ---- フォーム ---- */
.reg-form { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 18px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; }
.field label { font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
.field input[type=text], .field input[type=password], .field textarea, .field input[type=file] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .95rem; font-family: inherit;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21, 101, 192, .12);
}
.hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; }

.btn {
  border: none; border-radius: 8px; padding: 9px 18px; font-size: .9rem;
  cursor: pointer; font-family: inherit; transition: background .15s, opacity .15s;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--ghost { background: #eceff1; color: var(--text); }
.btn--ghost:hover { background: #dde3e7; }
.btn--sm { padding: 5px 12px; font-size: .8rem; }

/* ---- 登録済みメッセージの管理（削除） ---- */
.msg-manage { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 16px; }
.msg-manage__head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.msg-manage__head h3 { margin: 0; font-size: .95rem; }
.msg-manage__list { list-style: none; margin: 0; padding: 0; }
.msg-manage__list li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
  background: #fafbfc;
}
.msg-manage__text {
  flex: 1; white-space: pre-line; font-size: .9rem; word-break: break-word;
}
.msg-manage__list form { margin: 0; }
.btn-del {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  border: none; cursor: pointer; font-size: 1.1rem; line-height: 1;
  background: #ffebee; color: #c62828; transition: background .15s;
}
.btn-del:hover { background: #ef9a9a; color: #fff; }

/* ---- 写真コーナー ---- */
.photos-area h2 { border-bottom: 2px solid var(--primary); padding-bottom: 8px; }
.lead { color: var(--muted); font-size: .9rem; }
code { background: #eceff1; padding: 1px 6px; border-radius: 4px; font-size: .85em; }

.activity {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 12px; overflow: hidden;
}
.activity__link {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: none; border: none; padding: 14px 18px; cursor: pointer;
  font-size: 1.02rem; font-family: inherit; color: var(--text); text-align: left;
}
.activity__link:hover { background: #f5f8fc; }
.chevron { transition: transform .2s; color: var(--primary); font-size: .8rem; }
.activity__link[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.activity__name { flex: 1; font-weight: 600; }
.activity__count { color: var(--muted); font-size: .82rem; }

.activity__gallery { padding: 0 18px 18px; }
.gallery-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.thumb {
  display: block; border-radius: 8px; overflow: hidden; aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.thumb:hover img { transform: scale(1.05); }
/* 動画サムネイル：先頭フレーム＋再生アイコン */
.thumb--video { position: relative; background: #000; }
.thumb--video video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none; transition: transform .2s;
}
.thumb--video:hover video { transform: scale(1.05); }
.thumb__play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; padding-left: 3px; pointer-events: none;
}
.empty { color: var(--muted); }

.site-footer {
  text-align: center; color: var(--muted); font-size: .85rem;
  padding: 24px 0; margin-top: 20px;
}

/* ---- 浮遊メッセージ（備考欄チップス） ---- */
.floating-messages {
  position: fixed; inset: 0; z-index: 900;
  pointer-events: none;      /* 背後の操作を邪魔しない */
  overflow: hidden;
}
.chip {
  position: absolute;
  padding: 8px 12px;
  font-size: .92rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: left;          /* チップは左寄せ表示 */
  background: transparent;   /* チップは透明（文字のみ表示） */
  text-shadow: 0 1px 3px rgba(255, 255, 255, .85), 0 0 2px rgba(255, 255, 255, .85);
  pointer-events: auto;      /* チップ自体はホバー可能 */
  animation-name: chip-float;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
/* 本文の両側の空白領域（ガター）に配置。左寄せで統一 */
.chip--left  { right: calc(50vw + 548px); max-width: calc(50vw - 560px); }
.chip--right { left:  calc(50vw + 548px); max-width: calc(50vw - 560px); }

/* 本文：最大3行まで表示（縦オーバーは隠す） */
.chip__body { max-height: calc(1.4em * 3); overflow: hidden; }
/* 各行：収まらない場合は「…」で省略 */
.chip__line {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 削除ボタン（右上、ホバー時に表示） */
.chip__del {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px; border-radius: 50%;
  border: none; cursor: pointer; display: none;
  background: #c62828; color: #fff; font-size: .8rem; line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35); text-shadow: none;
}
.chip__del:hover { background: #e53935; }

/* ホバー時：3行制限・行内省略を解除し、全文を折り返し表示。削除ボタンも表示 */
.chip:hover {
  z-index: 950;
  filter: brightness(1.05);
  animation-play-state: paused;  /* 揺れを止めて全文を読みやすく */
}
.chip:hover .chip__body { max-height: none; overflow: visible; }
.chip:hover .chip__line { white-space: normal; overflow: visible; }
.chip:hover .chip__del { display: block; }

.chip--blue   { color: #1565c0; }
.chip--green  { color: #2e7d32; }
.chip--orange { color: #ef6c00; }
.chip--purple { color: #6a1b9a; }
.chip--pink   { color: #c2185b; }

/* ガターが確保できない狭い画面では浮遊メッセージを表示しない */
@media (max-width: 1199px) {
  .floating-messages { display: none; }
}

@keyframes chip-float {
  0%   { transform: translateY(0) rotate(-1deg); }
  50%  { transform: translateY(-16px) rotate(1.5deg); }
  100% { transform: translateY(0) rotate(-1deg); }
}
@media (prefers-reduced-motion: reduce) {
  .chip { animation: none; }
}

/* ---- 写真拡大ライトボックス ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, .88);
  display: flex; align-items: center; justify-content: center;
}
/* 通常モード（非プレビュー時）は非表示。初期表示・✖ボタンでの終了に必要 */
.lightbox[hidden] { display: none; }
.lb-image[hidden] { display: none; }
.lb-video { background: #000; }
.lb-stage {
  flex: 1; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 12px;
}
.lb-image {
  max-width: 90vw; max-height: 82vh;
  object-fit: contain; border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
}
.lb-close {
  position: absolute; top: 16px; right: 20px;
  background: none; border: none; color: #fff;
  font-size: 2.2rem; line-height: 1; cursor: pointer; opacity: .8;
}
.lb-close:hover { opacity: 1; }
.lb-nav {
  flex: 0 0 auto; z-index: 1;
  background: rgba(255, 255, 255, .12); color: #fff;
  border: none; cursor: pointer;
  width: 56px; height: 56px; margin: 0 10px;
  border-radius: 50%; font-size: 2rem; line-height: 1;
  transition: background .15s;
}
.lb-nav:hover { background: rgba(255, 255, 255, .28); }
.lb-toolbar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  background: rgba(0, 0, 0, .45); padding: 8px 16px; border-radius: 999px;
}
.lb-counter { color: #fff; font-size: .9rem; min-width: 54px; text-align: center; }
#lb-play.is-playing { background: var(--primary); color: #fff; }
