/* === リセット・基本設定 === */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #0d1a14;
  --bg-secondary: #112218;
  --bg-card: rgba(15,35,25,0.85);
  --bg-card-hover: rgba(22,48,34,0.9);
  --text-primary: #e4f0ea;
  --text-secondary: #8aab96;
  --text-muted: #527060;
  --accent-main: #4ade80;
  --accent-teal: #2dd4bf;
  --accent-valorant: #ff4655;
  --accent-aiit: #00d4ff;
  --accent-game: #7c4dff;
  --accent-manga: #ff6b9d;
  --accent-anime: #ffa726;
  --accent-event: #66bb6a;
  --sidebar-bg: #091410;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}


/* === ヘッダー === */
#header {
  padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: 8px;
  background: linear-gradient(135deg, #091410 0%, #0d1a14 50%, #0f1f17 100%);
  border-bottom: 1px solid rgba(77,222,128,0.1);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.app-title {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #4ade80 0%, #2dd4bf 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s;
}
.icon-btn:active {
  background: rgba(255,255,255,0.08);
  transform: scale(0.9);
}
.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}
/* お気に入りタブボタン */
.fav-btn {
  position: relative;
}
.fav-btn .fav-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: #ff4655;
  border-radius: 50%;
  display: none;
}
.fav-btn .fav-badge.show { display: block; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === サイドバー === */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: var(--sidebar-bg);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 20px) 16px 16px;
  border-bottom: 1px solid rgba(77,222,128,0.1);
}
.sidebar-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
}
.sidebar-app-name {
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, #4ade80 0%, #2dd4bf 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-cat-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.sidebar-cat-btn:active { transform: scale(0.97); }
.sidebar-cat-btn.active {
  background: rgba(77,222,128,0.1);
  color: var(--text-primary);
  font-weight: 700;
}
.sidebar-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === カテゴリバー === */
.category-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  position: relative;
  z-index: 10;
}
.cat-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-bar-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* === メインコンテンツ === */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
  z-index: 1;
}


/* === Pull to Refresh === */
.ptr-indicator {
  text-align: center;
  padding: 0;
  height: 0;
  overflow: hidden;
  transition: height 0.2s, padding 0.2s;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ptr-indicator.pulling {
  height: 40px;
  padding: 8px 0;
}
.ptr-indicator.refreshing {
  height: 40px;
  padding: 8px 0;
}
.ptr-indicator .ptr-chibi {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}
.ptr-indicator.refreshing .ptr-chibi {
  animation: bounce 0.6s ease-in-out infinite;
}

/* === ニュースリスト === */
.news-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 10px calc(var(--safe-bottom) + 12px);
  min-height: 0;
}

/* コンパクトカード */
.news-card {
  display: flex;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  border: 1px solid rgba(255,255,255,0.04);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.news-card:active {
  background: var(--bg-card-hover);
  transform: scale(0.985);
}

/* カード左のアクセントライン */
.news-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--card-accent, #7c4dff);
  opacity: 0.6;
}

/* カード内キャラ装飾 */
.card-chibi {
  position: absolute;
  right: 6px;
  bottom: -4px;
  width: 28px;
  height: 28px;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.news-card-body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.news-source {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 500;
}
.source-time {
  margin-left: auto;
  opacity: 0.7;
  white-space: nowrap;
}
.news-source .source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.news-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}


.news-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-secondary);
  position: relative;
  z-index: 1;
}

/* お気に入りボタン */
.fav-star {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0,0,0,0.3);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.2s;
  padding: 0;
}
.fav-star svg {
  width: 14px;
  height: 14px;
}
.fav-star:active { transform: scale(0.85); }
.fav-star.favorited {
  background: rgba(255,107,157,0.3);
}
.fav-star.favorited svg {
  fill: #ff6b9d;
  stroke: #ff6b9d;
}

/* === ローディング === */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.loading-chibi {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
  animation: bounce 1s ease-in-out infinite;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-aiit);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}

/* === エラー === */
.error-msg {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.error-msg .retry-btn {
  margin-top: 10px;
  padding: 7px 18px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
}

/* === 空状態 === */
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.empty-state .empty-char {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 10px;
  opacity: 0.7;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* === スクロールバー === */
.news-list::-webkit-scrollbar { width: 3px; }
.news-list::-webkit-scrollbar-track { background: transparent; }
.news-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

/* === アニメーション === */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.news-card {
  animation: fadeInUp 0.25s ease backwards;
}

/* お気に入りタブ空 */
.fav-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}
.fav-empty .fav-empty-icon {
  font-size: 36px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* === 設定モーダル === */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.settings-modal.open {
  pointer-events: auto;
  opacity: 1;
}

.settings-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.settings-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  max-height: 75vh;
  background: #1a1f35;
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s ease;
  overflow: hidden;
}
.settings-modal.open .settings-panel {
  transform: translateY(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 0;
  flex-shrink: 0;
}

.settings-title {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #4ade80, #2dd4bf);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.settings-desc {
  padding: 4px 16px 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(var(--safe-bottom) + 20px);
}

.settings-category {
  margin-bottom: 16px;
}

.settings-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 8px 0 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 6px;
}

.settings-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.settings-feed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.feed-toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  outline: none;
}
.feed-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.feed-toggle:checked {
  background: #4ade80;
}
.feed-toggle:checked::after {
  transform: translateX(20px);
}

.feed-label {
  flex: 1;
  font-size: 14px;
  color: var(--text-secondary);
}

.feed-tag {
  font-size: 10px;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
}

/* === 既読カード === */
.news-card.read {
  opacity: 0.5;
}
.news-card.read .news-title {
  color: var(--text-muted);
}

/* === 最終更新バー === */
.last-updated-bar {
  flex-shrink: 0;
  text-align: center;
  padding: 4px 12px;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* === スワイプヒント === */
.swipe-area {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.swipe-area .news-list {
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.swipe-area .news-list.swipe-left {
  transform: translateX(-30px);
  opacity: 0.3;
}
.swipe-area .news-list.swipe-right {
  transform: translateX(30px);
  opacity: 0.3;
}

/* === 背景ちびキャラ装飾 === */
#main-content::after,
.sidebar::after,
.settings-panel::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 240px;
  height: 240px;
  background-repeat: no-repeat;
  background-position: bottom right;
  background-size: contain;
  pointer-events: none;
  opacity: 0.2;
  z-index: 2;
}
#main-content::after {
  background-image: url('assets/characters/akashi_chibi.png');
}
.sidebar::after {
  background-image: url('assets/characters/akashi_chibi_wrench.png');
}
.settings-panel::after {
  background-image: url('assets/characters/akashi_chibi_shy.png');
}
