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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f8fafc;
  color: #334155;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ヘッダー */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2px 0;
  margin-bottom: 2px;
  border-radius: 0 0 20px 20px;
}

.header h1 {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.header-subtitle {
  text-align: center;
  opacity: 0.9;
  font-size: 1.1rem;
}

/* コントロールパネル */
.controls {
  background: white;
  padding: 5px;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  margin-bottom: 2px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
}

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

.per-page-control label {
  font-weight: 500;
  color: #64748b;
}

.per-page-input {
  width: 80px;
  padding: 0.5rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
}

.per-page-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.btn-secondary.active {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  min-height: 32px;
}

/* 検索ボックス */
.search-box {
  background: white;
  padding: 5px;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
}

.search-input-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 1rem;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-input-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-btn {
  padding: 0.8rem 0.8rem;
  background: #f1f5f9;
  color: #475569;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 48px;
  flex-shrink: 0;
}

.search-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.search-btn:active {
  transform: translateY(0);
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  display: none;
  align-items: center;
  justify-content: center;
}

.clear-search-btn.visible {
  display: flex;
}

.clear-search-btn:hover {
  background: #f1f5f9;
  color: #64748b;
  transform: translateY(-50%) scale(1.2);
}

.search-info {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #64748b;
}

.search-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.keyword-tag {
  background: #667eea;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ステータス */
.status {
  text-align: center;
  padding: 5px;
  font-size: 1.1rem;
  color: #64748b;
  margin-bottom: 1px;
}

/* ニュース項目 */
.news-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.news-item {
  background: white;
  border-radius: 8px;
  padding: 0.8rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  border: 1px solid #e2e8f0;
}

.news-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.news-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #64748b;
  flex: 1;
  min-width: 0;
}

.news-number {
  background: #667eea;
  color: white;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 500;
  font-size: 0.75rem;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.news-date, .news-company {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-date {
  flex-shrink: 0;
}

.news-company {
  flex: 1;
  min-width: 0;
}

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

.fav-btn, .save-btn {
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0.3rem;
  border-radius: 4px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  flex-shrink: 0;
}

.fav-btn:hover, .save-btn:hover {
  background: #f1f5f9;
  transform: scale(1.1);
}

.fav-btn.active {
  color: #fbbf24;
  background: #fffbeb;
}

.news-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: #1e293b;
  cursor: pointer;
  transition: color 0.2s;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.news-title:hover {
  color: #667eea;
}

/* 保存ファイル情報 */
.saved-file-info {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #64748b;
}

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

.pagination .btn {
  min-width: 44px;
  justify-content: center;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  overflow: auto;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white;
  max-width: 900px;
  margin: 0 auto;
  border-radius: 20px;
  position: relative;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
  padding: 2rem;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  padding-right: 60px;
}

.modal-meta {
  opacity: 0.9;
  font-size: 0.95rem;
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 2rem;
}

.modal-fav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-radius: 12px;
}

.modal-fav-btn {
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0.5rem;
  border-radius: 50%;
  background: white;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #e2e8f0;
}

.modal-fav-btn:hover {
  transform: scale(1.1);
  border-color: #fbbf24;
}

.modal-fav-btn.active {
  color: #fbbf24;
  background: #fffbeb;
  border-color: #fbbf24;
}

.article-content {
  background: #f8fafc;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  line-height: 1.7;
}

.modal-actions {
  padding: 1.5rem 2rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* 保存されたファイル一覧のスタイル */
.saved-files-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: white;
}

.saved-file-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.saved-file-item:hover {
  background: #f8fafc;
}

.saved-file-item:last-child {
  border-bottom: none;
}

.saved-file-name {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
  word-break: break-all;
}

.saved-file-meta {
  font-size: 0.8rem;
  color: #64748b;
}

.saved-file-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .button-group {
    justify-content: center;
  }
  
  .news-meta {
    flex-wrap: wrap;
  }
  
  .modal {
    padding: 10px;
  }
  
  .modal-content {
    max-height: 95vh;
  }
  
  .modal-header,
  .modal-body,
  .modal-actions {
    padding: 1.5rem;
  }
  
  .modal-title {
    font-size: 1.3rem;
  }
  
  .modal-actions {
    flex-direction: column;
  }

  .saved-file-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
  }
  
  .news-title {
    font-size: 1.1rem;
  }
  
  .modal-header,
  .modal-body,
  .modal-actions {
    padding: 1rem;
  }
}

/* ローディングアニメーション */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* スムーズスクロール */
html {
  scroll-behavior: smooth;
}

/* フォーカス表示の改善 */
.btn:focus,
.per-page-input:focus,
.fav-btn:focus,
.modal-fav-btn:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* ダークモード対応の準備 */
@media (prefers-color-scheme: dark) {
  /* 必要に応じてダークモードスタイルを追加 */
}