:root {
  /* Brand Colors */
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-dark: #134e4a;
  --primary-light: #f0fdfa;
  --primary-muted: #ccfbf1;
  --primary-border: #99f6e4;
  --accent: #2dd4bf;

  /* Text */
  --text-primary: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-on-dark: #ffffff;

  /* Surface */
  --surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --border: #e2e8f0;

  /* Semantic */
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --info-bg: #f0f9ff;
  --info-text: #075985;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-card: 24px;
  --radius-btn: 12px;
  --radius-pill: 9999px;

  /* Shadow */
  --shadow-soft: 0 4px 20px -2px rgba(15,23,42,0.05);
  --shadow-lift: 0 20px 40px -5px rgba(13,148,136,0.15);
  --ring-primary: 0 0 0 3px rgba(13, 148, 136, 0.1);

  /* Semantic Hover */
  --error-hover: #fecaca;

  /* Animation */
  --duration-fast: 150ms;
  --duration-normal: 200ms;

  /* Layout */
  --max-width: 1280px;
  --max-width-text: 640px;

  /* Font */
  --font-sans: 'Pretendard', 'Inter', system-ui, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-body);
  background-color: var(--bg-subtle);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Header */
.header {
  padding: var(--space-12) 0 var(--space-8);
  text-align: center;
}

.header__title {
  font-size: 48px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.header__subtitle {
  font-size: 16px;
  color: var(--text-muted);
}

/* Search Bar */
.search-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: var(--space-5);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 56px;
  padding: 0 var(--space-5) 0 52px;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-btn);
  outline: none;
  transition: border-color var(--duration-normal), box-shadow var(--duration-normal);
}

.search-input::placeholder {
  color: var(--text-subtle);
}

.search-input:focus {
  border-color: var(--primary-border);
  box-shadow: var(--ring-primary);
}

.search-btn {
  height: 56px;
  padding: 0 var(--space-6);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-on-dark);
  background: var(--primary);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: background var(--duration-fast);
  white-space: nowrap;
}

.search-btn:hover {
  background: var(--primary-hover);
}

.search-btn svg {
  width: 20px;
  height: 20px;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-4);
  background: var(--bg-subtle);
  border-radius: var(--radius-btn);
  margin-bottom: var(--space-6);
}

.filter-bar__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.filter-select,
.filter-input {
  height: 40px;
  padding: 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  outline: none;
  transition: border-color var(--duration-normal);
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--primary-border);
}

.filter-input {
  width: 120px;
}

.filter-input::placeholder {
  color: var(--text-subtle);
}

.filter-separator {
  font-size: 14px;
  color: var(--text-subtle);
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

/* Result Card */
.result-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--duration-normal), transform var(--duration-normal);
  animation: fadeUp 0.4s ease both;
}

.result-card:hover {
  box-shadow: var(--shadow-lift);
  transform: translateY(-4px);
}

.result-card__image-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-muted);
}

.result-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-card__info {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.result-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: var(--space-1);
}

.result-card__price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-1);
}

.result-card__price--empty {
  color: var(--text-subtle);
  font-size: 13px;
  font-weight: 500;
}

.result-card__description {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-card__date {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* Loading Spinner */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-16) 0;
}

.loading--more {
  padding: var(--space-8) 0;
}

.ai-search-icon {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  animation: ai-breathe 2s ease-in-out infinite;
  overflow: hidden;
  border-radius: 50%;
}

.ai-search-icon--small {
  width: 32px;
  height: 32px;
}

.ai-scan-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  border-radius: 1px;
  animation: ai-scan 1.8s ease-in-out infinite;
}

.loading-ellipsis::after {
  content: '';
  animation: ellipsis 1.5s steps(3) infinite;
}

.loading__text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-16) 0;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-subtle);
}

.empty-state__text {
  font-size: 16px;
}

/* Error State */
.error-state {
  padding: var(--space-5);
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius-btn);
  text-align: center;
  margin-bottom: var(--space-6);
}

.error-state__text {
  font-size: 16px;
}

/* Sentinel (infinite scroll trigger) */
.sentinel {
  height: 1px;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes ai-breathe {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes ai-scan {
  0% { top: 20%; opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { top: 75%; opacity: 0; }
}

@keyframes ellipsis {
  0% { content: ''; }
  33% { content: '.'; }
  66% { content: '..'; }
  100% { content: '...'; }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== Admin Dashboard ========== */

/* Admin Header */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

.admin-header__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.admin-header__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.admin-header__badge {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
}

.admin-header__logout {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.admin-header__logout:hover {
  color: var(--error-text);
  border-color: var(--error-text);
}

.admin-header__logout svg {
  width: 16px;
  height: 16px;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: var(--space-1);
  background: var(--bg-muted);
  padding: var(--space-1);
  border-radius: var(--radius-btn);
  margin-bottom: var(--space-6);
}

.admin-tabs__btn {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.admin-tabs__btn:hover {
  color: var(--text-body);
}

.admin-tabs__btn--active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-soft);
}

/* Admin Panel */
.admin-panel {
  margin-bottom: var(--space-8);
}

/* Period Selector */
.admin-period {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.admin-period__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: var(--space-2);
}

.admin-period__btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-muted);
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.admin-period__btn:hover {
  color: var(--text-body);
}

.admin-period__btn--active {
  background: var(--primary);
  color: var(--text-on-dark);
}

/* Admin Card */
.admin-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.admin-card__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.admin-card__value {
  font-size: 40px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Section Title */
.admin-section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

/* Top Queries */
.admin-top-queries {
  list-style: none;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: var(--space-4);
  margin-bottom: var(--space-8);
}

.admin-top-queries__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.admin-top-queries__item:last-child {
  border-bottom: none;
}

.admin-top-queries__query {
  font-size: 16px;
  color: var(--text-body);
}

.admin-top-queries__count {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* Daily Chart (CSS bar chart) */
.admin-chart {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: var(--space-4);
  margin-bottom: var(--space-8);
}

.admin-chart__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
}

.admin-chart__label {
  flex-shrink: 0;
  width: 90px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.admin-chart__bar-wrap {
  flex: 1;
  height: 24px;
  background: var(--bg-muted);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.admin-chart__bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-btn);
  min-width: 2px;
  transition: width var(--duration-normal);
}

.admin-chart__value {
  flex-shrink: 0;
  width: 50px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-body);
  font-variant-numeric: tabular-nums;
}

.admin-chart__empty {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-6);
}

/* Cache Status */
.admin-cache-status {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.admin-cache-actions {
  margin-bottom: var(--space-6);
}

.admin-cache-query {
  display: flex;
  gap: var(--space-3);
}

/* Admin Buttons */
.admin-btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background var(--duration-fast);
  white-space: nowrap;
}

.admin-btn--danger {
  background: var(--error-bg);
  color: var(--error-text);
}

.admin-btn--danger:hover {
  background: var(--error-hover);
}

.admin-btn--secondary {
  background: var(--bg-muted);
  color: var(--text-body);
}

.admin-btn--secondary:hover {
  background: var(--border);
}

/* Admin Input */
.admin-input {
  flex: 1;
  height: 44px;
  padding: 0 var(--space-4);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  outline: none;
  transition: border-color var(--duration-normal);
}

.admin-input::placeholder {
  color: var(--text-subtle);
}

.admin-input:focus {
  border-color: var(--primary-border);
}

/* Toggle Switch */
.admin-settings-list {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.admin-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.admin-toggle:last-child {
  border-bottom: none;
}

.admin-toggle__label {
  font-size: 16px;
  color: var(--text-body);
}

.admin-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.admin-toggle__switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  transition: background var(--duration-fast);
}

.admin-toggle__switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform var(--duration-fast);
}

.admin-toggle__input:checked + .admin-toggle__switch {
  background: var(--primary);
}

.admin-toggle__input:checked + .admin-toggle__switch::after {
  transform: translateX(20px);
}

/* Settings Status */
.admin-settings-status {
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-btn);
  text-align: center;
}

.admin-settings-status--success {
  background: var(--success-bg);
  color: var(--success-text);
}

.admin-settings-status--error {
  background: var(--error-bg);
  color: var(--error-text);
}

.admin-settings-status--info {
  background: var(--info-bg);
  color: var(--info-text);
}

/* Confirm Modal */
.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.admin-modal {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lift);
  padding: var(--space-8);
  max-width: 400px;
  width: calc(100% - var(--space-8));
}

.admin-modal__text {
  font-size: 16px;
  color: var(--text-body);
  margin-bottom: var(--space-6);
  text-align: center;
}

.admin-modal__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* Admin Mobile */
@media (max-width: 767px) {
  .admin-header__title {
    font-size: 20px;
  }

  .admin-card__value {
    font-size: 28px;
  }

  .admin-cache-status {
    grid-template-columns: 1fr;
  }

  .admin-cache-query {
    flex-direction: column;
  }

  .admin-chart__label {
    width: 70px;
    font-size: 14px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Desktop (>=1024px) - default styles above */

/* Tablet (768px~1023px) */
@media (max-width: 1023px) {
  .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Mobile (<768px) */
@media (max-width: 767px) {
  .header__title {
    font-size: 32px;
  }

  .header__subtitle {
    font-size: 15px;
  }

  .container {
    padding: 0 var(--space-4);
  }

  .search-bar {
    flex-direction: column;
  }

  .search-btn {
    width: 100%;
    justify-content: center;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-input {
    width: 100%;
  }

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

  .header {
    padding: var(--space-8) 0 var(--space-6);
  }
}
