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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Header */
header {
  text-align: center;
  padding: 30px 0 20px;
}

header h1 {
  font-size: 1.8rem;
  color: #2d3748;
  margin-bottom: 8px;
}

.subtitle {
  color: #718096;
  font-size: 0.95rem;
}

.back-link {
  color: #4a7cf7;
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* Search Section */
.search-section {
  text-align: center;
  padding: 20px 0;
}

.search-form {
  margin-bottom: 30px;
}

#search-input {
  width: 100%;
  max-width: 600px;
  padding: 16px 24px;
  font-size: 1.1rem;
  border: 2px solid #e2e8f0;
  border-radius: 50px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}

#search-input:focus {
  border-color: #4a7cf7;
  box-shadow: 0 0 0 3px rgba(74, 124, 247, 0.15);
}

/* Provider Buttons */
.provider-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.provider-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 100px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  padding: 12px;
}

.provider-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.provider-btn.yahoo {
  border-color: #ff0033;
}
.provider-btn.yahoo:hover {
  background: #fff5f5;
}
.provider-btn.yahoo .provider-icon {
  background: #ff0033;
}

.provider-btn.amazon {
  border-color: #ff9900;
}
.provider-btn.amazon:hover {
  background: #fffaf0;
}
.provider-btn.amazon .provider-icon {
  background: #ff9900;
}

.provider-btn.rakuten {
  border-color: #bf0000;
}
.provider-btn.rakuten:hover {
  background: #fff5f5;
}
.provider-btn.rakuten .provider-icon {
  background: #bf0000;
}

.provider-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #fff;
  font-weight: bold;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.provider-name {
  font-size: 0.85rem;
  color: #4a5568;
  text-align: center;
  line-height: 1.3;
}

.hint {
  color: #a0aec0;
  font-size: 0.85rem;
}

/* Results Page */
.results-search-bar {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.results-search-bar #search-input {
  margin-bottom: 12px;
}

.provider-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.tab-btn {
  padding: 8px 20px;
  border: 2px solid #e2e8f0;
  border-radius: 25px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  color: #4a5568;
}

.tab-btn:hover {
  background: #f7fafc;
}

.tab-btn.active {
  color: #fff;
  font-weight: bold;
}

.tab-btn.yahoo.active {
  background: #ff0033;
  border-color: #ff0033;
}

.tab-btn.amazon.active {
  background: #ff9900;
  border-color: #ff9900;
}

.tab-btn.rakuten.active {
  background: #bf0000;
  border-color: #bf0000;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: #718096;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #4a7cf7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.product-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

.product-card a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.product-image {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: #fafafa;
  padding: 10px;
}

.product-info {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-size: 0.9rem;
  color: #2d3748;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.product-price {
  font-size: 1.15rem;
  font-weight: bold;
  color: #e53e3e;
  margin-top: auto;
}

.product-shop {
  font-size: 0.75rem;
  color: #a0aec0;
  margin-top: 4px;
}

.product-provider {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: bold;
  color: #fff;
  margin-top: 6px;
  align-self: flex-start;
}

.product-provider.yahoo { background: #ff0033; }
.product-provider.amazon { background: #ff9900; }
.product-provider.rakuten { background: #bf0000; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0;
}

.page-btn {
  padding: 10px 24px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  background: #f7fafc;
  border-color: #4a7cf7;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-info {
  color: #718096;
  font-size: 0.9rem;
}

/* Error */
.error-message {
  background: #fff5f5;
  color: #e53e3e;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 0.9rem;
}

.success-message {
  background: #f0fff4;
  color: #38a169;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 0.9rem;
}

/* Admin */
.admin-section {
  max-width: 700px;
  margin: 0 auto;
}

.admin-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.admin-desc {
  color: #718096;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.settings-group {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.settings-group:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-heading {
  font-size: 1rem;
  margin-bottom: 12px;
  padding-left: 10px;
  border-left: 3px solid #ccc;
}

.yahoo-heading { border-left-color: #ff0033; color: #ff0033; }
.amazon-heading { border-left-color: #ff9900; color: #ff9900; }
.rakuten-heading { border-left-color: #bf0000; color: #bf0000; }

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: #4a5568;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #4a7cf7;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: #4a7cf7;
  color: #fff;
}

.btn-primary:hover {
  background: #3b6ce4;
}

.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

.btn-secondary:hover {
  background: #cbd5e0;
}

.info-card {
  background: #f7fafc;
  border: 1px dashed #cbd5e0;
}

.info-card h2 {
  font-size: 1rem;
  color: #4a5568;
  margin-bottom: 8px;
}

.info-card p {
  font-size: 0.85rem;
  color: #718096;
  margin-bottom: 12px;
}

.env-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.env-table th, .env-table td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.env-table th {
  color: #4a5568;
  font-weight: 600;
}

.env-table code {
  background: #edf2f7;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 30px 0 10px;
}

.admin-link {
  color: #a0aec0;
  text-decoration: none;
  font-size: 0.85rem;
}

.admin-link:hover {
  color: #4a7cf7;
}

/* No results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: #a0aec0;
}

.no-results h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: #718096;
}

/* Responsive */
@media (max-width: 640px) {
  .provider-buttons {
    flex-direction: column;
    align-items: center;
  }

  .provider-btn {
    width: 100%;
    max-width: 300px;
    flex-direction: row;
    height: auto;
    gap: 12px;
  }

  .provider-name br {
    display: none;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .provider-tabs {
    flex-direction: column;
    align-items: stretch;
  }
}
