@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: #fdf6f0;
  color: #333;
}

/* ヘッダー */
header {
  background-color: #fdf0e8;
  padding: 0;
  line-height: 0;
  position: relative;
}

.header-twitter-link {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  text-decoration: none;
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
  z-index: 10;
  line-height: 1.4;
}

.header-twitter-link:hover {
  background: rgba(0, 0, 0, 0.65);
}

.header-logo-img {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  object-position: center;
  display: block;
}

.auth-bar {
  background: #fff8f3;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  padding: 8px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-inner { display: none; }

/* サイドバーレイアウト */
.layout-container {
  display: flex;
  margin: 0 auto;
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: #fdf6f0;
  border-right: 1px solid #f0e8e0;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-search {
  padding: 0 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 12px;
}

.sidebar-search input,
.sidebar-search select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  background: #fafafa;
  color: #333;
}

.sidebar-section-title {
  padding: 0 14px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.main-content {
  flex: 1;
  min-width: 0;
}

/* ギャラリー（マソンリーレイアウト） */
.gallery {
  columns: 4;
  column-gap: 12px;
  padding: 12px 16px;
}

.loading-msg {
  column-span: all;
  text-align: center;
  color: #999;
  padding: 60px 0;
}

.gallery-item {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  break-inside: avoid;
  margin-bottom: 12px;
  display: inline-block;
  width: 100%;
}

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

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
}

/* ホバー時オーバーレイ */
.item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.72));
  padding: 28px 10px 10px;
  opacity: 0;
  transition: opacity 0.22s;
  pointer-events: none;
}

.gallery-item:hover .item-overlay {
  opacity: 1;
  pointer-events: auto;
}

.item-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: white;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.genre-tag {
  background: rgba(255,255,255,0.22);
  color: white;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  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: 4000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  position: relative;
}

.modal-image-wrap {
  position: relative;
  flex: 0 0 68%;
  background: #f0ede8;
  border-radius: 0;
  overflow: hidden;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-right-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0;
  border-left: 1px solid #eee;
}

.modal-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.modal-action-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 12px 24px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eee;
  background: white;
}

#modalImgFavBtn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}
#modalImgFavBtn:hover { background: rgba(233,30,99,0.7); }
#modalImgFavBtn.favorited { background: rgba(233,30,99,0.85); }

#downloadBtn {
  position: absolute;
  bottom: 10px;
  right: 52px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}
#downloadBtn:hover { background: rgba(0,0,0,0.75); }

.modal-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.close-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  z-index: 10;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.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;
  margin-top: auto;
}

.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;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.genre-tab {
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

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

.genre-tab.active {
  background: #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; }

/* モーダル内 共有ボタン */
.modal-share-btn {
  background: none;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.2s;
}
.modal-share-btn:hover { border-color: #1a1a2e; }

/* モーダル内 編集・削除ボタン */
.modal-edit-btn, .modal-delete-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.modal-edit-btn { background: #f0f0f0; color: #333; }
.modal-edit-btn:hover { background: #e0e0e0; }
.modal-delete-btn { background: #ffebee; color: #c62828; }
.modal-delete-btn:hover { background: #ffcdd2; }

/* 認証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;
  font-weight: 600;
  color: #333 !important;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: rgba(255,255,255,0.7);
  color: #555;
  border: 1px solid rgba(0,0,0,0.15);
  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.9); }

/* ログイン誘導トースト */
.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;
}

/* マイページ（全画面スライドパネル） */
.mypage-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: #f5f5f5;
  z-index: 3000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.mypage-panel.active {
  transform: translateX(0);
}

.mypage-topbar {
  background: #1a1a2e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.mypage-back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.mypage-back-btn:hover { background: rgba(255,255,255,0.15); }

.mypage-topbar-title {
  font-size: 1rem;
  font-weight: 700;
}

.mypage-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 20px 20px;
  background: white;
  border-bottom: 1px solid #eee;
}

.mypage-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #eee;
}

#mypageName {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1a1a2e;
}

.mypage-tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid #eee;
  padding: 0 16px;
  position: sticky;
  top: 52px;
  z-index: 5;
}

.mypage-tab {
  padding: 14px 24px;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  color: #999;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}

.mypage-tab.active {
  color: #1a1a2e;
  font-weight: 600;
  border-bottom-color: #1a1a2e;
}

.mypage-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding: 16px;
  align-items: start;
}

.mypage-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #bbb;
  font-size: 0.9rem;
  padding: 60px 0;
}

.mypage-card {
  border-radius: 12px;
  overflow: hidden;
  background: white;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  height: fit-content;
}
.mypage-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.13); }
.mypage-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.mypage-card-meta { padding: 10px; }
.mypage-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mypage-card-genre {
  font-size: 0.72rem;
  color: #2196F3;
  margin-top: 3px;
}
.mypage-card-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 3px;
}
.mypage-card-actions button {
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 5px;
  color: white;
  font-size: 0.75rem;
  padding: 4px 7px;
  cursor: pointer;
}

/* ユーザー情報クリッカブル */
.user-info {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 20px;
  transition: background 0.2s;
}
.user-info:hover { background: rgba(0,0,0,0.08); }

/* 自分の投稿の編集・削除ボタン */
.own-post-btns {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.own-post-btns button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.own-post-btns button:hover { opacity: 1; background: #f5f5f5; }

/* 投稿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: 4500;
  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: 900px) and (min-width: 601px) {
  .sidebar { width: 160px; }
  .gallery { columns: 3; }
}

/* スマホ */
@media (max-width: 600px) {
  .header-logo-img { max-height: 140px; }
  .auth-bar { padding: 6px 14px; }
  .login-btn { padding: 8px 14px; font-size: 0.8rem; }
  #userName { display: none; }
  .login-toast { font-size: 0.8rem; padding: 12px 16px; bottom: 16px; }

  /* モーダル：スマホは縦並びに戻す */
  .modal-content {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }
  .modal-image-wrap {
    flex: 0 0 50%;
    height: 50vh;
    padding: 12px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    align-items: center;
    justify-content: center;
  }
  .modal-right-panel {
    flex: 0 0 50%;
    height: 50vh;
    overflow: hidden;
    min-height: 0;
  }
  .modal-scroll-area {
    overflow-y: auto;
    height: 100%;
  }
  .close-btn {
    right: auto;
  }
  .modal-content img { max-height: 100%; }

  /* サイドバー → 上部横並びに変換 */
  .layout-container { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid #eee;
    padding: 12px 0 0;
  }

  .sidebar-search {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 12px 12px;
    gap: 8px;
  }

  .sidebar-search input { flex: 1; min-width: 130px; }
  .sidebar-search select { flex: 0 0 auto; width: auto; }

  .sidebar-section-title { display: none; }

  /* ジャンルタブ → 折り返し複数行 */
  .genre-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 0 12px 10px;
    gap: 6px;
  }

  .genre-tab {
    flex-shrink: 0;
    padding: 7px 16px;
    border-radius: 20px;
    border: 2px solid #ddd;
    background: white;
    color: #333;
    width: auto;
    text-align: center;
  }
  .genre-tab:hover { border-color: #1a1a2e; background: white; color: #1a1a2e; }
  .genre-tab.active { background: #1a1a2e; border-color: #1a1a2e; color: white; }

  .gallery {
    columns: 2;
    column-gap: 8px;
    padding: 10px 10px;
  }
  .gallery-item { margin-bottom: 8px; }
}
