/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --c-red: #e60012;
  --c-red-dark: #b3000e;
  --c-orange: #ff9900;
  --c-orange-dark: #cc7a00;
  --c-bg: #f5f5f5;
  --c-white: #fff;
  --c-text: #333;
  --c-text-light: #666;
  --c-border: #ddd;
  --c-shadow: rgba(0,0,0,0.08);
  --font-main: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --radius: 8px;
  --max-w: 1200px;
}

body {
  font-family: var(--font-main);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
.header {
  background: var(--c-red);
  color: var(--c-white);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px var(--c-shadow);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.tagline {
  font-size: 0.85rem;
  opacity: 0.85;
}

.settings-btn {
  margin-left: auto;
  background: none;
  border: 2px solid rgba(255,255,255,0.5);
  color: var(--c-white);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.settings-btn:hover {
  border-color: var(--c-white);
}

/* === Main === */
.main {
  flex: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  padding: 20px;
  position: relative;
}

/* === Search Form === */
.search-form {
  margin-bottom: 24px;
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font-main);
}

.search-input:focus {
  border-color: var(--c-red);
}

.search-submit {
  padding: 12px 28px;
  background: var(--c-red);
  color: var(--c-white);
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-main);
}

.search-submit:hover {
  background: var(--c-red-dark);
}

.search-options {
  margin-top: 8px;
  display: flex;
  gap: 12px;
}

.sort-select {
  padding: 6px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--c-white);
  font-family: var(--font-main);
}

/* === Results Header === */
.results-header {
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--c-text-light);
}

/* === Results Grid === */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.column-title {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--c-white);
  margin-bottom: 12px;
}

.column-title--rakuten {
  background: var(--c-red);
}

.column-title--amazon {
  background: var(--c-orange);
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* === Product Card === */
.product-card {
  background: var(--c-white);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px var(--c-shadow);
  overflow: hidden;
  display: flex;
  gap: 12px;
  padding: 12px;
  transition: box-shadow 0.2s;
}

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

.product-image {
  width: 100px;
  height: 100px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fafafa;
  border-radius: 4px;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.product-price {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--c-red);
  margin-bottom: 4px;
}

.product-rating {
  font-size: 0.8rem;
  color: var(--c-text-light);
  margin-bottom: 8px;
}

.product-rating .stars {
  color: #f5a623;
  letter-spacing: 1px;
}

.product-link {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c-white);
  text-decoration: none;
  border-radius: 4px;
  transition: opacity 0.2s;
}

.product-link:hover {
  opacity: 0.85;
}

.product-link--rakuten {
  background: var(--c-red);
}

.product-link--amazon {
  background: var(--c-orange);
}

/* === Empty / Error State === */
.empty-state,
.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--c-text-light);
  font-size: 0.9rem;
}

.error-state {
  color: var(--c-red);
}

/* === Loading === */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 50;
  font-size: 0.9rem;
  color: var(--c-text-light);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* === Skeleton === */
.skeleton-card {
  background: var(--c-white);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 12px;
}

.skeleton-img,
.skeleton-line {
  background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

.skeleton-img {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 14px;
}

.skeleton-line:first-child {
  width: 80%;
}

.skeleton-line:nth-child(2) {
  width: 40%;
  height: 20px;
}

.skeleton-line:nth-child(3) {
  width: 60%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* === Settings === */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-panel {
  background: var(--c-white);
  border-radius: var(--radius);
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.settings-header h2 {
  font-size: 1.2rem;
}

.settings-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--c-text-light);
  line-height: 1;
}

.settings-panel fieldset {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.settings-panel legend {
  font-weight: 700;
  padding: 0 8px;
}

.settings-panel label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--c-text-light);
}

.settings-panel input[type="text"] {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: var(--font-main);
}

.settings-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-main);
}

.btn--primary {
  background: var(--c-red);
  color: var(--c-white);
}

.btn--secondary {
  background: var(--c-border);
  color: var(--c-text);
}

.settings-note {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--c-text-light);
}

/* === Footer === */
.footer {
  text-align: center;
  padding: 20px;
  font-size: 0.75rem;
  color: var(--c-text-light);
  border-top: 1px solid var(--c-border);
  margin-top: 40px;
}

.footer p + p {
  margin-top: 4px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .results-grid {
    grid-template-columns: 1fr;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .logo {
    font-size: 1.3rem;
  }

  .tagline {
    display: none;
  }

  .product-card {
    padding: 10px;
  }

  .product-image {
    width: 80px;
    height: 80px;
  }
}
