/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: var(--bg-solid);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text-primary);
  line-height: 1.6;
  transition: all 0.4s ease;
}

/* ===== Default Theme Variables ===== */
:root {
  --bg-gradient: linear-gradient(135deg, #0f172a, #581c87, #0f172a);
  --bg-solid: #0f172a;
  --thumb-fade-color: color-mix(in srgb, var(--bg-solid) 85%, transparent);
  --text-primary: #fff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #a855f7;
  --accent-secondary: #c084fc;
  --accent-glow: rgba(168, 85, 247, 0.4);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --card-hover: rgba(168, 85, 247, 0.5);
  --tag-bg: rgba(34, 211, 238, 0.2);
  --tag-border: #22d3ee;
  --tag-text: #67e8f9;
  --btn-bg: rgba(255, 255, 255, 0.1);
  --btn-text: #cbd5e1;
  --menu-bg: rgba(15, 23, 42, 0.98);
  --font-heading: "Audiowide", sans-serif;
  --font-ui-accent: "Roboto Condensed", "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  --hub-badge-bg: linear-gradient(110deg, rgba(94, 234, 212, 0.25), rgba(14, 165, 233, 0.28), rgba(192, 132, 252, 0.32));
  --hub-badge-text: #e0f2fe;
}

/* ===== Hamburger Menu ===== */
.hamburger {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.3s ease;
}

.hamburger:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--accent-glow);
}

.hamburger span {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: var(--text-primary);
  transition: all 0.3s ease;
  border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Help Button ===== */
.help-btn {
  position: fixed;
  top: 1.25rem;
  right: 5rem;
  z-index: 1000;
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.help-btn:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--accent-glow);
}

@media (max-width: 768px) {
  .help-btn {
    display: none;
  }

  body.menu-open .help-btn {
    display: flex;
  }
}

/* ===== Overlay ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Side Menu ===== */
.side-menu {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100vh;
  background: var(--menu-bg);
  backdrop-filter: blur(20px);
  z-index: 999;
  padding: 5rem 1.5rem 2rem;
  overflow-y: auto;
  transition: right 0.4s ease;
  border-left: 1px solid var(--card-border);
}

.side-menu.active {
  right: 0;
}

.menu-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-left: 0.5rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  border-radius: 0.75rem;
  border: 2px solid var(--card-border);
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s ease;
}

.theme-btn:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.theme-btn.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
}

.theme-preview {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.theme-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Side Menu: main menu + panels ===== */
.menu-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.25s ease;
}

.menu-item {
  text-decoration: none;
  /* ← 追加 */
}

.menu-item:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
  transform: translateY(-1px);
}

.menu-item-icon {
  font-size: 1.1rem;
}

.menu-item-text {
  flex: 1;
  text-align: left;
}

.menu-item-arrow {
  font-size: 1.1rem;
  opacity: 0.7;
}

.menu-panel {
  display: none;
}

.menu-panel.active {
  display: block;
}

.menu-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--card-border);
  background: var(--btn-bg);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-back:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.menu-panel-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--menu-bg);
  border: 1px solid var(--card-border);
  border-radius: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

.modal-close {
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--btn-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-close:hover {
  background: var(--accent-primary);
  color: var(--bg-solid);
}

.modal-body {
  padding: 1.5rem;
}

.help-section {
  margin-bottom: 1.5rem;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section h3 {
  font-size: 0.875rem;
  color: var(--accent-primary);
  margin-bottom: 0.75rem;
}

.help-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.help-item kbd {
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  background: var(--btn-bg);
  border: 1px solid var(--card-border);
  font-size: 0.75rem;
  color: var(--text-primary);
}

/* ===== Header ===== */
.header {
  padding: 2.75rem 1.5rem 0;
  /* 上少し詰める＋下は0 */
  text-align: center;
  margin-bottom: 0.75rem;
  /* ヘッダー全体と検索の間 */
}

.welcome {
  font-size: 0.68rem;
  color: var(--accent-secondary);
  margin-bottom: 2rem;
  /* ロゴ〜テキストの間を少しだけ */
  animation: fadeIn 0.5s ease;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.1rem, 3.4vw + 0.6rem, 3rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  line-height: 1.2;
  font-variation-settings: 'wdth' 75;
  margin-bottom: 1.5rem;
}

.logo-mark {
  width: clamp(2.6rem, 4vw, 3.6rem);
  height: clamp(1.65rem, 2.6vw, 2.4rem);
  display: inline-block;
  background: var(--hub-badge-bg, linear-gradient(110deg, rgba(94, 234, 212, 0.25), rgba(14, 165, 233, 0.28), rgba(192, 132, 252, 0.32)));
  mask-image: url('../img/logo.svg');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: url('../img/logo.svg');
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  flex-shrink: 0;
}

.header h1 span {
  color: var(--hub-badge-text, inherit);
  padding: 0.15rem 0.5rem;
  border-radius: 0.85rem;
  background: var(--hub-badge-bg, linear-gradient(110deg, rgba(94, 234, 212, 0.25), rgba(14, 165, 233, 0.28), rgba(192, 132, 252, 0.32)));
  box-shadow: 0 10px 40px rgba(14, 165, 233, 0.25);
}

.header h1 .logo-mark {
  padding: 0;
  border-radius: 0;
  background: var(--hub-badge-bg, linear-gradient(110deg, rgba(94, 234, 212, 0.25), rgba(14, 165, 233, 0.28), rgba(192, 132, 252, 0.32)));
  box-shadow: none;
}

.header p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  max-width: 32rem;
  margin: 0 auto 1rem auto;
}

.welcome-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.welcome-line span {
  line-height: 19px;
}

.weather-toggle {
  border: 1px solid var(--accent-secondary);
  background: transparent;
  color: var(--accent-secondary);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.62rem;
  height: 19px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.weather-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.welcome-message {
  color: transparent;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(120deg, #7dd3fc, #c084fc, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  padding: 0.2rem 0.4rem;
  text-shadow: 0 0 0 rgba(0, 0, 0, 0);
  animation: welcomePulse 6s ease-in-out infinite;
}

.welcome-weather {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.3s ease;
  color: var(--text-secondary);
  font-size: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border-radius: 10px;
  padding: 0 0.75rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.welcome-weather.show {
  max-height: 200px;
  opacity: 1;
  padding: 0.75rem;
}

@keyframes welcomePulse {
  0% {
    text-shadow: 0 0 14px rgba(125, 211, 252, 0.35);
  }
  50% {
    text-shadow: 0 0 20px rgba(192, 132, 252, 0.6);
  }
  100% {
    text-shadow: 0 0 14px rgba(125, 211, 252, 0.35);
  }
}

/* ===== Filters layout (階層整理) ===== */
.filters {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0;
}

.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.1) 37%, rgba(255, 255, 255, 0.05) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.filters-top {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  /* 検索とコントロールの間 */
  margin-bottom: 0.75rem;
  padding: 0;
}

.filters-middle {
  margin-bottom: 0rem;
  /* カテゴリ〜タグの間 */
}

.filters-bottom {
  margin-bottom: 0.75rem;
  /* タグ〜カード一覧の間 */
}

.search-box-wrapper {
  padding: 0 1.5rem;
  ;
}

.search-box {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto 0.75rem;
  display: block;
  padding: 0.875rem 1.25rem 0.875rem 3rem;
  border-radius: 9999px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
}

.search-box:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--accent-glow);
}

.search-box::placeholder {
  color: var(--text-muted);
}

/* ===== Controls ===== */
.controls {
  display: flex;
  justify-content: end;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 1.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.control-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.view-toggle {
  display: flex;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.view-btn {
  padding: 0.5rem 0.75rem;
  border: none;
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s ease;
}

.view-btn.active {
  background: var(--accent-primary);
  color: var(--bg-solid);
}

.view-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ===== Categories - Horizontal Scroll ===== */
.categories-wrapper {
  position: relative;
  margin-bottom: 0.75rem;
  padding: 0 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  width: 100%;
}

/* スクロールバー非表示（WebKit） */
.categories-wrapper::-webkit-scrollbar {
  display: none;
}

.categories {
  display: flex;
  gap: 0.75rem;

  /* カテゴリ行は「中身の分だけ幅を持つ帯」にする */
  width: max-content;
  margin: 0;
  padding: 0.5rem 0;
}

@keyframes cat-select-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent-glow);
  }
  70% {
    box-shadow: 0 0 0 12px transparent;
  }
  100% {
    box-shadow: 0 10px 25px -5px var(--accent-glow);
  }
}

@keyframes tag-select-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent-glow);
    transform: translateY(0);
  }
  60% {
    box-shadow: 0 0 0 10px transparent;
    transform: translateY(-2px);
  }
  100% {
    box-shadow: 0 6px 18px -6px var(--accent-glow);
    transform: translateY(-1px);
  }
}

@media (min-width: 1024px) {
  .categories-wrapper {
    display: flex;
    justify-content: center;
  }

  .categories-wrapper.is-overflowing {
    justify-content: flex-start;
  }

  .categories {
    margin: 0 auto;
  }

  .categories-wrapper.is-overflowing .categories {
    margin: 0;
  }
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font-ui-accent);
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  background: var(--btn-bg);
  color: var(--btn-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.cat-btn:hover {
  background: var(--card-hover);
  color: var(--text-primary);
}

.cat-btn.active {
  background: var(--accent-primary);
  color: var(--bg-solid);
  box-shadow: 0 10px 25px -5px var(--accent-glow);
  transform: scale(1.05);
  animation: cat-select-pulse 0.32s ease;
}

.cat-count {
  font-size: 0.75rem;
  opacity: 0.8;
}

/* ===== Keyboard Hint ===== */
.hint {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hint {
  display: none !important;
}

.hint kbd {
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  background: var(--btn-bg);
  border: 1px solid var(--card-border);
  font-size: 0.7rem;
  margin: 0 0.125rem;
}

/* ===== Tags ===== */
.tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.tag-btn {
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-secondary);
}

.tag-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.tag-btn.active {
  border-color: var(--tag-border);
  background: var(--tag-bg);
  color: var(--tag-text);
  animation: tag-select-pulse 0.28s ease;
  box-shadow: 0 6px 18px -6px var(--accent-glow);
  transform: translateY(-1px);
}

.clear-btn {
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #f87171;
  transition: opacity 0.2s ease, color 0.2s ease;
}

/* タグ選択0件のときに使う「目立たない状態」 */
.clear-btn.clear-btn-disabled {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* ===== Favorites Section ===== */
.fav-section {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
  display: none;
}

.fav-section.show {
  display: block;
}

.fav-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.fav-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.fav-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.fav-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  text-decoration: none;
  transition: all 0.3s ease;
}

.fav-card:hover {
  border-color: var(--card-hover);
  transform: translateY(-2px);
}

.fav-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-solid);
  font-weight: 700;
}

.fav-title {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-remove {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fav-remove:hover {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
}

/* ===== Main Container ===== */
.container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ===== Grid ===== */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.grid.list-view {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--card-border);
  transition: all 0.4s ease;
  text-decoration: none;
  display: block;
  position: relative;
}

.card:hover {
  border-color: var(--card-hover);
  box-shadow: 0 25px 50px -12px var(--accent-glow);
  transform: translateY(-4px);
}

.card-thumb {
  position: relative;
  height: 11rem;
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.card:hover .card-thumb img {
  transform: scale(1.1);
}

.card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--thumb-fade-color), transparent);
  opacity: 0.8;
}

/* ===== Thumbnail Placeholder (サムネなし時) ===== */
.card-thumb-placeholder {
  position: relative;
  height: 11rem;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-thumb-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 0%, transparent 30%);
}

.card-thumb-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--thumb-fade-color), transparent);
  opacity: 0.6;
}

.card-thumb-placeholder .placeholder-icon {
  font-size: 4rem;
  z-index: 1;
  opacity: 0.9;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  transition: transform 0.5s ease;
}

.card:hover .card-thumb-placeholder .placeholder-icon {
  transform: scale(1.1) rotate(5deg);
}

.card-thumb-placeholder .placeholder-letter {
  font-size: 5rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  z-index: 1;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.5s ease;
}

.card:hover .card-thumb-placeholder .placeholder-letter {
  transform: scale(1.15);
}

.card-thumb-placeholder .badges {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.375rem;
  z-index: 2;
}

.card-thumb-placeholder .card-fav {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
}

.badges {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.375rem;
  z-index: 1;
}

.badge-new {
  padding: 0.25rem 0.625rem;
  background: linear-gradient(135deg, #f43f5e, #ec4899);
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 700;
  font-family: var(--font-ui-accent);
  color: #fff;
  text-transform: uppercase;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.card-fav {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.card-fav:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

.card-fav.active {
  color: #fbbf24;
}

.card-fav svg {
  width: 1.25rem;
  height: 1.25rem;
}

.card-tags {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.375rem;
  z-index: 30;
}

.card-thumb-placeholder .card-tags {
  z-index: 30;
}

.card-tag {
  padding: 0.125rem 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.card-body {
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-solid);
  font-weight: 700;
  font-size: 1.125rem;
  flex-shrink: 0;
}

/* サイトアイコン画像対応 */
.card-icon {
  position: relative;
  overflow: hidden;
}

.card-icon.card-icon-has-img {
  background: transparent;
}

/* 中の画像 */
.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 頭文字テキスト */
.card-icon-initial {
  position: relative;
  z-index: 1;
}

/* 画像があるときは頭文字を非表示 */
.card-icon-has-img .card-icon-initial {
  display: none;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  font-family: var(--font-ui-accent);
  color: var(--text-primary);
  transition: color 0.3s ease;
}

.card:hover .card-title {
  color: var(--accent-secondary);
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-link {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  color: var(--accent-primary);
  font-size: 0.875rem;
  font-weight: 500;
}

.card-link svg {
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  transition: transform 0.3s ease;
}

.card:hover .card-link svg {
  transform: translateX(4px);
}

/* ===== List View ===== */
.grid.list-view .card {
  display: flex;
  align-items: center;
}

.grid.list-view .card-thumb {
  width: 100px;
  height: 70px;
  margin: 0.75rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
}

.grid.list-view .card-thumb::after {
  display: none;
}

.grid.list-view .card-thumb-placeholder {
  width: 100px;
  height: 70px;
  margin: 0.75rem;
  border-radius: 0.5rem;
  flex-shrink: 0;
}

.grid.list-view .card-thumb-placeholder .placeholder-icon {
  font-size: 2rem;
}

.grid.list-view .card-thumb-placeholder .badges {
  top: 0.25rem;
  left: 0.25rem;
}

.grid.list-view .card-thumb-placeholder .card-fav {
  position: relative;
  top: auto;
  right: auto;
}

.grid.list-view .badges {
  top: 0.5rem;
  left: 0.5rem;
}

.grid.list-view .card-fav {
  position: relative;
  top: auto;
  right: auto;
  margin-right: 0.75rem;
  background: var(--btn-bg);
}

.grid.list-view .card-tags {
  display: none;
}

.grid.list-view .card-body {
  flex: 1;
  padding: 0.75rem 0.75rem 0.75rem 0;
  min-width: 0;
}

.grid.list-view .card-head {
  margin-bottom: 0.25rem;
}

.grid.list-view .card-icon {
  width: 2rem;
  height: 2rem;
  font-size: 0.875rem;
}

.grid.list-view .card-title {
  font-size: 1rem;
}

.grid.list-view .card-desc {
  -webkit-line-clamp: 1;
}

.grid.list-view .card-link {
  display: none;
}

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 4rem 1rem;
  grid-column: 1 / -1;
}

.empty .icon {
  font-size: 3.75rem;
  margin-bottom: 1rem;
}

.empty h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.empty p {
  color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--card-border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-family: var(--font-ui-accent);
}

/* ===== PWA Install Prompt ===== */
.install {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--menu-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.install.show {
  opacity: 1;
  visibility: visible;
}

.install p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.install-btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent-primary);
  color: var(--bg-solid);
  font-weight: 600;
  cursor: pointer;
}

.install-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}
