@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* ヘッダー */
header {
  background: #1a1a2e;
  color: white;
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.header-inner {
  text-align: center;
}

header h1 {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f9c4e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
}

header p {
  opacity: 0.7;
  font-size: 0.9rem;
}

/* フィルター */
.filters {
  display: flex;
  gap: 12px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.filters input,
.filters select {
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  flex: 1;
  min-width: 200px;
  background: white;
}

#sortSelect {
  flex: 0 0 auto;
  min-width: unset;
  width: auto;
}

/* ギャラリー */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.loading-msg {
  grid-column: 1 / -1;
  text-align: center;
  color: #999;
  padding: 60px 0;
}

.gallery-item {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.item-meta {
  padding: 12px;
}

.item-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #333;
}

.genre-tag {
  background: #e8f4fd;
  color: #2196F3;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  display: inline-block;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 700px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-image-wrap {
  position: relative;
  height: min(55vh, 420px);
  background: #f8f8f8;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}

.modal-content img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  z-index: 10;
  line-height: 1;
}

.prompt-section {
  padding: 24px;
}

.prompt-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  margin-bottom: 12px;
}

.prompt-text {
  background: #f8f8f8;
  border-radius: 8px;
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.copy-btn {
  margin-top: 16px;
  background: #1a1a2e;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #2d2d5e;
}

.copy-btn.copied {
  background: #4CAF50;
}

.meta-tags {
  display: flex;
  gap: 8px;
  padding: 0 24px 24px;
  flex-wrap: wrap;
}

.tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
}

.tag.genre {
  background: #e8f4fd;
  color: #2196F3;
}

.tag.tool {
  background: #f3e5f5;
  color: #9C27B0;
}

/* 管理ページ */
.admin-container {
  max-width: 600px;
  margin: 60px auto;
  padding: 20px;
}

.admin-container h1 {
  margin-bottom: 32px;
  font-size: 1.5rem;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
}

.form-group input[type="text"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group textarea {
  height: 160px;
  resize: vertical;
}

.image-preview {
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  display: none;
}

.image-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

.submit-btn {
  width: 100%;
  background: #1a1a2e;
  color: white;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.submit-btn:hover {
  background: #2d2d5e;
}

.submit-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.status-msg {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}

.status-msg.success {
  background: #e8f5e9;
  color: #2E7D32;
  display: block;
}

.status-msg.error {
  background: #ffebee;
  color: #C62828;
  display: block;
}

/* ジャンルタブ */
.genre-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.genre-tab {
  padding: 8px 18px;
  border: 2px solid #ddd;
  border-radius: 24px;
  background: white;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.genre-tab:hover {
  border-color: #1a1a2e;
  color: #1a1a2e;
}

.genre-tab.active {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: white;
}

/* お気に入り */
.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.35);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 32px;
  text-align: center;
  color: white;
  transition: background 0.2s, transform 0.15s;
  z-index: 1;
}
.fav-btn:hover {
  background: rgba(0,0,0,0.55);
  transform: scale(1.1);
}
.fav-btn.favorited { color: #e91e63; }

.modal-fav-btn {
  background: none;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: #aaa;
  transition: all 0.2s;
  flex-shrink: 0;
}
.modal-fav-btn:hover { border-color: #e91e63; color: #e91e63; }
.modal-fav-btn.favorited { border-color: #e91e63; color: #e91e63; background: #fff0f5; }

/* 認証UI */
.auth-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  color: #333;
  border: none;
  padding: 9px 18px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.login-btn:hover { background: #f0f0f0; transform: scale(1.02); }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.4);
}

#userName {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.9);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}
.logout-btn:hover { background: rgba(255,255,255,0.25); }

/* ログイン誘導トースト */
.login-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1a2e;
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 9999;
  transition: transform 0.3s ease;
  white-space: nowrap;
}
.login-toast.show { transform: translateX(-50%) translateY(0); }
.login-toast button {
  background: white;
  color: #1a1a2e;
  border: none;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* いいね数 */
.like-count {
  font-size: 0.7rem;
  margin-left: 2px;
  opacity: 0.9;
}

/* 投稿FABボタン */
.post-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1a1a2e;
  color: white;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 500;
  transition: transform 0.2s, background 0.2s;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.post-fab:hover { background: #2d2d5e; transform: scale(1.08); }

/* 投稿モーダル */
.post-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}
.post-modal.active { display: flex; }

.post-modal-content {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

.post-drop-zone {
  border: 2px dashed #ddd;
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}

/* レスポンシブ */
@media (max-width: 600px) {
  header h1 { font-size: 1.5rem; }
  header { padding: 20px 16px 16px; }
  .login-btn { padding: 8px 14px; font-size: 0.8rem; }
  #userName { display: none; }
  .login-toast { font-size: 0.8rem; padding: 12px 16px; bottom: 16px; }
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}
