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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: #0d1117;
  color: #e6edf3;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

a {
  color: #58a6ff;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== App Layout ===== */
.app-layout {
  display: flex;
  height: 100vh;
}

/* ===== Mobile Header ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 0.6rem 1rem;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #e6edf3;
  border-radius: 1px;
}

.mobile-title {
  font-size: 1rem;
  color: #e6edf3;
  font-weight: 600;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: #0d1117;
  border-right: 1px solid #21262d;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.25rem 1rem 0.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.sidebar-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e6edf3;
}

.sidebar-year {
  font-size: 0.8rem;
  color: #ffa657;
  font-weight: 600;
}

.sidebar-meta {
  padding: 0 1rem 1rem;
  font-size: 0.75rem;
  color: #484f58;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #c9d1d9;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.nav-item:hover {
  background: #161b22;
}

.nav-item.active {
  background: #1f6feb;
  color: #fff;
}

.nav-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.2rem;
  text-align: center;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  font-size: 0.75rem;
  color: #8b949e;
  min-width: 1.5rem;
  text-align: right;
}

.nav-item.active .nav-count {
  color: rgba(255, 255, 255, 0.7);
}

/* Nav Groups */
.nav-group {
  margin-top: 0.5rem;
}

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
}

.nav-group-header:hover {
  background: #161b22;
}

.nav-chevron {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.nav-group.collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.nav-group.collapsed .nav-group-items {
  display: none;
}

.nav-group-items {
  padding-left: 0.5rem;
}

.nav-group-items .nav-item {
  padding-left: 1.5rem;
  font-size: 0.82rem;
}

/* Gender accent in sidebar */
.nav-item[data-gender="girls"].active {
  background: #d63384;
}

.nav-item[data-gender="boys"].active {
  background: #1f6feb;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid #21262d;
}

.sidebar-sources {
  font-size: 0.65rem;
  color: #484f58;
  line-height: 1.5;
}

/* ===== Sidebar Overlay (mobile) ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ===== Feed Main ===== */
.feed-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d1117;
}

/* Feed Toolbar */
.feed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #21262d;
  background: #161b22;
  gap: 1rem;
  flex-shrink: 0;
}

.feed-title {
  font-size: 1.1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  gap: 0.4rem;
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: #58a6ff;
}

.search-icon {
  font-size: 0.8rem;
  color: #484f58;
}

.search-input {
  border: none;
  background: transparent;
  color: #e6edf3;
  font-size: 0.85rem;
  outline: none;
  width: 160px;
}

.search-input::placeholder {
  color: #484f58;
}

.view-toggle {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.view-toggle:hover {
  border-color: #58a6ff;
  color: #58a6ff;
}

/* ===== Feed List ===== */
.feed-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Feed Item (compact list view) */
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #161b22;
  cursor: pointer;
  transition: background 0.12s;
}

.feed-item:hover {
  background: #161b22;
}

.feed-item-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.rank-1 { background: #e3b341; color: #0d1117; }
.rank-2 { background: #8b949e; color: #0d1117; }
.rank-3 { background: #a0652f; color: #fff; }
.rank-default { background: #21262d; color: #8b949e; }

.feed-item-body {
  flex: 1;
  min-width: 0;
}

.feed-item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}

.feed-item-category {
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 2rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.cat-girls {
  background: rgba(214, 51, 132, 0.15);
  color: #f778ba;
  border: 1px solid rgba(214, 51, 132, 0.25);
}

.cat-boys {
  background: rgba(31, 111, 235, 0.15);
  color: #58a6ff;
  border: 1px solid rgba(31, 111, 235, 0.25);
}

.feed-item-source {
  font-size: 0.7rem;
  color: #484f58;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.feed-item-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e6edf3;
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item-desc {
  font-size: 0.82rem;
  color: #8b949e;
  margin-bottom: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.feed-item .stars {
  color: #e3b341;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.feed-item .age-tag {
  font-size: 0.65rem;
  padding: 0.05rem 0.4rem;
  border-radius: 2rem;
  background: rgba(88, 166, 255, 0.1);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.feed-item .keyword-tag {
  font-size: 0.65rem;
  padding: 0.05rem 0.4rem;
  border-radius: 2rem;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  transition: all 0.15s;
}

.feed-item .keyword-tag.clickable {
  cursor: pointer;
}

.feed-item .keyword-tag.clickable:hover {
  background: rgba(88, 166, 255, 0.15);
  border-color: #58a6ff;
  color: #58a6ff;
}

.feed-item .keyword-tag.keyword-active {
  background: rgba(88, 166, 255, 0.2);
  border-color: #58a6ff;
  color: #58a6ff;
  font-weight: 600;
}

/* Feed item date */
.feed-item-date {
  font-size: 0.68rem;
  color: #586069;
  white-space: nowrap;
}

/* Expanded feed item */
.feed-item.expanded {
  background: #161b22;
  border-left: 3px solid #58a6ff;
  padding-left: calc(1.25rem - 3px);
}

.feed-item.expanded .feed-item-name {
  white-space: normal;
}

.feed-item.expanded .feed-item-desc {
  -webkit-line-clamp: unset;
  display: block;
}

.feed-item.expanded.gender-girls {
  border-left-color: #f778ba;
}

.feed-item.expanded.gender-boys {
  border-left-color: #58a6ff;
}

/* Category-colored expand borders */
.feed-item.expanded[data-category="fashion"] { border-left-color: #a855f7; }
.feed-item.expanded[data-category="beauty"] { border-left-color: #ec4899; }
.feed-item.expanded[data-category="gourmet"] { border-left-color: #fb923c; }
.feed-item.expanded[data-category="music"] { border-left-color: #34d399; }
.feed-item.expanded[data-category="sns"] { border-left-color: #60a5fa; }
.feed-item.expanded[data-category="lifestyle"] { border-left-color: #facc15; }
.feed-item.expanded[data-category="idol"] { border-left-color: #fb7185; }
.feed-item.expanded[data-category="gadget"] { border-left-color: #94a3b8; }
.feed-item.expanded[data-category="spot"] { border-left-color: #f472b6; }

/* ===== Card View ===== */
.feed-list.card-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.25rem;
}

.card-view .feed-item {
  flex-direction: column;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 1rem;
  border-bottom: 1px solid #30363d;
}

.card-view .feed-item:hover {
  border-color: #484f58;
  transform: translateY(-1px);
}

.card-view .feed-item.expanded {
  border-left: 3px solid #58a6ff;
  padding-left: calc(1rem - 3px);
}

.card-view .feed-item.expanded.gender-girls {
  border-left-color: #f778ba;
}

.card-view .feed-item-name {
  white-space: normal;
}

.card-view .feed-item-desc {
  -webkit-line-clamp: 3;
}

.card-view .feed-item-rank {
  margin-top: 0;
}

/* ===== Keyword Filter Bar ===== */
.keyword-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: rgba(88, 166, 255, 0.08);
  border-bottom: 1px solid rgba(88, 166, 255, 0.15);
  flex-shrink: 0;
}

.keyword-bar-label {
  font-size: 0.78rem;
  color: #8b949e;
}

.keyword-bar-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: #58a6ff;
}

.keyword-bar-clear {
  margin-left: auto;
  font-size: 0.75rem;
  color: #8b949e;
  background: transparent;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}

.keyword-bar-clear:hover {
  color: #e6edf3;
  border-color: #58a6ff;
}

/* ===== Feed Empty ===== */
.feed-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #484f58;
  font-size: 0.9rem;
}

/* ===== Section Divider in feed ===== */
.feed-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #8b949e;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 10;
}

.feed-section-date {
  font-size: 0.7rem;
  font-weight: 400;
  color: #484f58;
}

/* ===== Scrollbar ===== */
.feed-list::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.feed-list::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.feed-list::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 3px;
}

.feed-list::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #484f58;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .app-layout {
    padding-top: 48px;
    height: calc(100vh);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    min-width: 280px;
    z-index: 100;
    transition: left 0.25s ease;
    padding-top: 48px;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .feed-main {
    width: 100%;
  }

  .search-input {
    width: 100px;
  }

  .feed-list.card-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .feed-toolbar {
    padding: 0.5rem 0.75rem;
  }

  .feed-item {
    padding: 0.6rem 0.75rem;
  }

  .feed-title {
    font-size: 0.95rem;
  }
}
