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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
  background-color: #f5f5f5;
  color: #333;
}

header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  padding: 2rem;
  text-align: center;
}

.header-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  position: relative;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.expand-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.2s;
}

.expand-btn:hover {
  background: rgba(255,255,255,0.3);
  color: #fff;
}

header .description {
  opacity: 0.9;
  font-size: 1rem;
}

header .last-updated {
  margin-top: 1rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.controls input,
.controls select {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
}

.controls input {
  flex: 1;
  min-width: 200px;
}

.controls select {
  min-width: 150px;
  flex-shrink: 0;
}

.controls-buttons {
  display: contents;
}

.favorites-toggle {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #f0ad4e;
  border-radius: 8px;
  background: #fff;
  color: #f0ad4e;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.favorites-toggle:hover {
  background: #fff8e1;
}

.favorites-toggle.active {
  background: #f0ad4e;
  color: #fff;
}

.favorites-toggle .star {
  font-size: 1.1rem;
}

.clear-favorites {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border: 1px solid #dc3545;
  border-radius: 8px;
  background: #fff;
  color: #dc3545;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.clear-favorites:hover {
  background: #dc3545;
  color: #fff;
}

.resource-toggle {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #28a745;
  border-radius: 8px;
  background: #fff;
  color: #28a745;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.resource-toggle:hover {
  background: #e8f5e9;
}

.resource-toggle.active {
  background: #28a745;
  color: #fff;
}

.aidb-toggle {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid #0077b6;
  border-radius: 8px;
  background: #fff;
  color: #0077b6;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.aidb-toggle:hover {
  background: #e8f4f8;
}

.aidb-toggle.active {
  background: #0077b6;
  color: #fff;
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stats {
  color: #666;
  font-size: 0.9rem;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #666;
}

.pagination-size select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 0.85rem;
}

.papers-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

@media (min-width: 900px) {
  .papers-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .papers-list {
    grid-template-columns: repeat(3, 1fr);
  }
}

.paper-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s;
}

.paper-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.paper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.favorite-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #ccc;
  cursor: pointer;
  padding: 0.2rem;
  transition: all 0.2s;
  line-height: 1;
}

.favorite-btn:hover {
  color: #f0ad4e;
  transform: scale(1.2);
}

.favorite-btn.active {
  color: #f0ad4e;
}

.paper-card.is-favorite {
  border-left: 3px solid #f0ad4e;
}

.paper-date {
  background: #e8f4f8;
  color: #0077b6;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.paper-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.keyword-tag {
  background: #f0f0f0;
  color: #666;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.keyword-tag:hover {
  background: #0077b6;
  color: #fff;
}

.keyword-tag.active {
  background: #0077b6;
  color: #fff;
}

.keyword-more,
.keyword-less {
  color: #0077b6;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  background: #e8f4f8;
  border-radius: 4px;
  transition: all 0.2s;
}

.keyword-more:hover,
.keyword-less:hover {
  background: #0077b6;
  color: #fff;
}

.keyword-filter-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  background: #e8f4f8;
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  color: #0077b6;
}

.keyword-filter-indicator button {
  background: none;
  border: none;
  color: #0077b6;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
}

.keyword-filter-indicator button:hover {
  color: #005580;
}

.paper-id {
  color: #999;
  font-size: 0.8rem;
  font-family: monospace;
}

.paper-title {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.paper-title a {
  color: #1a1a2e;
  text-decoration: none;
}

.paper-title a:hover {
  color: #0077b6;
  text-decoration: underline;
}

.paper-title-ja {
  color: #555;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
  border-left: 3px solid #0077b6;
}

.paper-summary {
  background: #fafafa;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.paper-summary:hover {
  background: #f0f0f0;
}

.paper-summary strong {
  color: #0077b6;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.paper-summary .toggle-icon {
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.paper-summary.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.paper-summary p {
  font-size: 0.9rem;
  color: #444;
  transition: all 0.2s;
}

.paper-summary.collapsed p {
  display: none;
}

.paper-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.75rem;
}

.paper-authors {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
}

.paper-fetched {
  flex-shrink: 0;
  white-space: nowrap;
}

.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.paper-links a {
  color: #0077b6;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid #0077b6;
  border-radius: 4px;
  transition: all 0.2s;
}

.paper-links a:hover {
  background: #0077b6;
  color: #fff;
}

.paper-links a.resource-link {
  background: #28a745;
  border-color: #28a745;
  color: #fff;
}

.paper-links a.resource-link:hover {
  background: #218838;
  border-color: #218838;
}

.aidb-article {
  background: #e8f4f8;
  border-left: 3px solid #0077b6;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  border-radius: 0 6px 6px 0;
}

.aidb-article a {
  color: #0077b6;
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
}

.aidb-article a:hover {
  text-decoration: underline;
}

.paper-links a.chatgpt-link {
  background: #10a37f;
  border-color: #10a37f;
  color: #fff;
}

.paper-links a.chatgpt-link:hover {
  background: #0d8a6a;
  border-color: #0d8a6a;
}

.paper-links .copy-for-ai {
  background: #6c757d;
  border: 1px solid #6c757d;
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.paper-links .copy-for-ai:hover {
  background: #5a6268;
  border-color: #5a6268;
}

.paper-links .copy-for-ai.copied {
  background: #28a745;
  border-color: #28a745;
}

.loading,
.error,
.no-results {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.error {
  color: #d00;
}

/* ページネーション */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
  background: #0077b6;
  border-color: #0077b6;
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination button.active {
  background: #0077b6;
  border-color: #0077b6;
  color: #fff;
}

.pagination-ellipsis {
  color: #888;
  padding: 0 0.25rem;
}

footer {
  text-align: center;
  padding: 2rem;
  color: #888;
  font-size: 0.85rem;
}

footer a {
  color: #0077b6;
}

@media (max-width: 768px) {
  .controls {
    gap: 0.5rem;
  }

  .controls input {
    width: 100%;
    min-width: 100%;
    flex: none;
  }

  .controls select {
    flex: 1;
    min-width: 0;
  }

  .favorites-toggle,
  .clear-favorites,
  .resource-toggle,
  .aidb-toggle {
    flex: 1;
    min-width: calc(50% - 0.25rem);
    text-align: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 600px) {
  header h1 {
    font-size: 1.5rem;
  }

  .controls-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .paper-meta {
    flex-direction: column;
  }

  .pagination button {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }

  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-controls {
    flex-direction: column;
  }
}

/* Header Navigation */
.header-nav {
  margin-top: 1rem;
}

.header-nav a {
  color: #fff;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.header-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #fff;
}

.back-link {
  display: inline-block;
}

/* Dashboard Styles */
.dashboard-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.dashboard-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

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

.control-group label {
  color: #666;
  font-size: 0.9rem;
}

.control-group select {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
}

/* Stats Cards */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-number {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: #0077b6;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.85rem;
  color: #666;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.chart-container {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.chart-container h2 {
  font-size: 1rem;
  color: #333;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e8f4f8;
}

.chart-container canvas {
  max-height: 300px;
  width: 100% !important;
  height: auto !important;
  min-height: 200px;
}

/* Ranking List */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
}

.ranking-item .rank {
  width: 24px;
  height: 24px;
  background: #0077b6;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.ranking-item .category-name {
  flex: 1;
  font-size: 0.9rem;
  color: #333;
}

.ranking-item .growth {
  font-weight: 600;
  font-size: 0.85rem;
}

.ranking-item .growth.positive {
  color: #22c55e;
}

.ranking-item .growth.negative {
  color: #ef4444;
}

.ranking-item .growth.neutral {
  color: #f59e0b;
}

/* Keyword Cloud */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.keyword-cloud .keyword {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: #e8f4f8;
  color: #0077b6;
  border-radius: 4px;
  transition: transform 0.2s;
}

.keyword-cloud .keyword:hover {
  transform: scale(1.1);
  background: #0077b6;
  color: #fff;
}

.no-data {
  text-align: center;
  color: #888;
  padding: 2rem;
}

/* Growth detail for rising keywords */
.growth-detail {
  font-size: 0.75rem;
  color: #888;
  margin-left: 0.5rem;
}

/* New keyword style */
.new-keyword {
  background: #dcfce7 !important;
  color: #166534 !important;
  border: 1px solid #86efac;
}

.new-keyword small {
  opacity: 0.7;
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-container.full-width {
    grid-column: 1;
  }

  .chart-container canvas {
    max-height: 250px;
    min-height: 180px;
  }

  .chart-container {
    padding: 1rem;
  }

  .chart-container h2 {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .chart-container canvas {
    max-height: 200px;
    min-height: 150px;
  }

  .stats-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-number {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }
}

/* ==========================================
   会員限定モーダル
   ========================================== */

.membership-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 1rem;
}

.membership-modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  border-radius: 16px;
  padding: 2rem 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.15);
  animation: modalBounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modalBounceIn {
  0% {
    opacity: 0;
    transform: translateY(-80px) scale(0.8);
  }
  60% {
    transform: translateY(15px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.membership-modal-content h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: #fff;
}

.membership-modal-content p {
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 0.75rem;
  line-height: 1.7;
}

.membership-modal-buttons {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.membership-btn {
  display: block;
  padding: 0.875rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.membership-btn.primary {
  background: linear-gradient(135deg, #0077b6 0%, #00b4d8 100%);
  color: #fff;
}

.membership-btn.primary:hover {
  background: linear-gradient(135deg, #005f8f 0%, #0096b6 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 119, 182, 0.4);
}

.membership-btn.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.membership-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* 非会員時のコントロール薄表示（オプション） */
body:not(.is-member) .controls input,
body:not(.is-member) .controls select {
  cursor: pointer;
}

body:not(.is-member) .controls input::placeholder {
  color: #999;
}
