/* =========================
   カラー変数
========================= */
:root {
  --bg: #f7faf7;
  --card: #ffffff;
  --text: #223126;
  --muted: #617264;
  --primary: #2f7d4a;
  --primary-dark: #23623a;
  --border: #d8e3d9;
  --danger: #c64636;
  --warning: #8a6d1d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  --radius: 18px;
}

/* =========================
   基本
========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* =========================
   レイアウト
========================= */
.page {
  width: min(960px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

/* =========================
   ヒーロー
========================= */
.hero {
  background: linear-gradient(135deg, #e8f5ea, #f7faf7);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.3;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

/* =========================
   カード
========================= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* =========================
   フォーム
========================= */
.form-grid {
  display: grid;
  gap: 18px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 1rem;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

input[type="checkbox"] {
  accent-color: var(--primary);
}

.help {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

/* =========================
   ボタン
========================= */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef4ef;
  color: #314236;
}

.btn-secondary:hover {
  background: #e3e9e4;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(0.96);
}

/* =========================
   通知
========================= */
.notice {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 18px;
  font-weight: 700;
  display: none;
}

.notice.show {
  display: block;
}

.notice.success {
  background: #e7f6ea;
  color: #1f6d36;
  border: 1px solid #bfe3c8;
}

.notice.error {
  background: #fdeaea;
  color: #9f2c22;
  border: 1px solid #f3c5c1;
}

.notice.info {
  background: #fff7df;
  color: #7c5b08;
  border: 1px solid #ecd79a;
}

/* =========================
   プレビュー
========================= */
.preview {
  margin-top: 12px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fcfffc;
  min-height: 80px;
}

.preview-image {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
}

/* =========================
   投稿一覧
========================= */
.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.post-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.post-card-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: #fcfffc;
}

.post-author {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.4;
  min-height: 2.8em;
  max-height: 2.8em;
  overflow: hidden;
  word-break: break-word;
}

.post-image-wrap {
  width: 100%;
  background: #f3f7f3;
}

.post-image {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.post-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.post-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.post-date {
  font-size: 0.95rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf6ef;
  color: #2f7d4a;
  font-size: 0.9rem;
  font-weight: 700;
}

.badge.cat-news {
  background: #e3f2fd;
  color: #1565c0;
}

.badge.cat-event {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge.cat-topic {
  background: #fff3e0;
  color: #ef6c00;
}

.badge.cat-flower {
  background: #eef7ee;
  color: #3d7a4b;
}

.post-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  max-height: 5.4em;
  overflow: hidden;
}

.post-admin-meta {
  display: flex;
  justify-content: flex-start;
}

.small {
  font-size: 0.9rem;
  color: var(--muted);
}

.image-error {
  padding: 16px;
  background: #fff3f3;
  color: #a33a32;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

/* =========================
   管理画面共通
========================= */
.admin-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.admin-login {
  display: grid;
  gap: 12px;
}

hr.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* =========================
   画像モーダル
========================= */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}

.image-modal.hidden {
  display: none;
}

.image-modal-inner {
  position: relative;
  max-width: min(96vw, 1200px);
  max-height: 92vh;
}

.image-modal img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.image-modal-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 999px;
  background: #ffffff;
  color: #233126;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.image-modal-close:hover {
  transform: scale(1.04);
}

/* =========================
   レスポンシブ
========================= */
@media (min-width: 700px) {
  .post-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .post-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100%, calc(100% - 18px));
    padding: 16px 0 32px;
  }

  input[type="text"],
  input[type="password"],
  input[type="file"],
  select,
  textarea {
    font-size: 16px;
    padding: 16px;
  }

  .form-grid {
    gap: 22px;
  }

  .hero,
  .card,
  .post-body {
    padding: 16px;
  }

  .btn {
    width: 100%;
    font-size: 1.05rem;
    padding: 16px;
  }

  .actions {
    flex-direction: column;
  }

  .post-image {
    height: 220px;
  }

  .preview-image {
    max-height: 240px;
  }
}

/* =========================
   index.html 強化UI
========================= */
.index-tools {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: end;
}

.index-tool-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.index-summary {
  margin-top: 14px;
  color: var(--muted);
  font-weight: 700;
}

/* 投稿カードをクリック可能に */
.post-card.is-clickable {
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.post-card.is-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.08);
}

/* 詳細モーダル */
.detail-modal-card {
  position: relative;
  width: min(960px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.detail-modal-body {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
}

.detail-modal-image-wrap {
  background: #f4f8f4;
}

.detail-modal-image-wrap img {
  width: 100%;
  height: 100%;
  max-height: 92vh;
  object-fit: cover;
  display: block;
}

.detail-modal-content {
  padding: 24px 22px 22px;
}

.detail-modal-header {
  margin-bottom: 14px;
}

.detail-author {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.detail-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.9;
  color: var(--text);
  font-size: 1rem;
}

/* スマホ */
@media (max-width: 720px) {
  .index-tools {
    grid-template-columns: 1fr;
  }

  .detail-modal-body {
    grid-template-columns: 1fr;
  }

  .detail-modal-content {
    padding: 18px 16px 16px;
  }

  .detail-modal-image-wrap img {
    max-height: 300px;
  }
}