/* Design tokens */
:root {
  --blue: #3182f6;
  --blue-bg: #ebf3fe;
  --blue-dark: #1b6fe8;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --t1: #191f28;
  --t2: #6b7684;
  --t3: #9ea7b2;
  --border: #e5e8eb;
  --red: #f04452;
  --amber: #f59e0b;
  --radius: 12px;
  --nav-h: 60px;
  --sh: 0 1px 4px rgba(0,0,0,.08);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; border: none; background: none; cursor: pointer; color: inherit; }
img { display: block; max-width: 100%; }

/* App shell */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
}

.screen {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
  min-height: 100dvh;
}

/* Bottom nav */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
  z-index: 100;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--t3);
  padding: 4px 0;
  transition: color .15s;
}

.tab.active { color: var(--blue); }

.tab svg { width: 24px; height: 24px; }

/* Skeleton */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skel {
  background: linear-gradient(90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 16px 12px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--t1);
}

.section-more {
  font-size: 13px;
  color: var(--t2);
}

/* ---- HOME ---- */
.home-status {
  background: var(--surface);
  padding: 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-status-left { display: flex; flex-direction: column; gap: 2px; }

.status-count {
  font-size: 24px;
  font-weight: 700;
  color: var(--blue);
}

.status-label {
  font-size: 13px;
  color: var(--t2);
}

.status-refresh {
  font-size: 11px;
  color: var(--t3);
  text-align: right;
}

/* Horizontal card scroll */
.h-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 16px;
  display: flex;
  gap: 10px;
  scrollbar-width: none;
}
.h-scroll-wrap::-webkit-scrollbar { display: none; }

.h-card {
  flex: 0 0 150px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--sh);
}

.h-card-photo {
  width: 100%;
  height: 100px;
  background: #f2f4f6;
  position: relative;
  overflow: hidden;
}

.h-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.h-card-body {
  padding: 10px;
}

.h-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
}

.h-card-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}

.h-card-deadline {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}

.h-card-apsl-pct {
  font-size: 11px;
  font-weight: 400;
  color: var(--t2);
}

/* D-day pill */
.dday-pill {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,.55);
  border-radius: 20px;
  padding: 2px 7px;
}
.dday-pill.urgent { background: var(--red); }
.dday-pill.soon { background: var(--amber); }

/* Ranking list */
.ranking-list { background: var(--surface); }

.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.ranking-item:last-child { border-bottom: none; }

.rank-no {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.rank-no.top { color: var(--t1); }

.rank-name {
  flex: 1;
  font-size: 14px;
  color: var(--t1);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Category shortcuts */
.cat-shortcuts {
  background: var(--surface);
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--t1);
  transition: background .15s;
}
.cat-btn:active { background: var(--border); }
.cat-btn .cat-icon { font-size: 22px; }

/* Intro banner */
.intro-banner {
  margin: 8px 16px 16px;
  padding: 16px;
  background: var(--blue-bg);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
}

.intro-banner-text { flex: 1; }
.intro-banner-title { font-size: 15px; font-weight: 700; color: var(--t1); margin-bottom: 4px; }
.intro-banner-desc { font-size: 13px; color: var(--t2); }
.intro-banner-arrow { font-size: 20px; color: var(--blue); }

/* ---- LIST ---- */
.list-top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.list-filter-row {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.list-filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  background: var(--surface);
  transition: all .15s;
  white-space: nowrap;
}
.filter-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.sort-row {
  display: flex;
  gap: 4px;
  padding: 6px 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.sort-row::-webkit-scrollbar { display: none; }

.sort-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--t3);
  transition: color .15s;
}
.sort-btn.active {
  color: var(--t1);
  font-weight: 700;
}

.list-count {
  padding: 10px 16px 6px;
  font-size: 13px;
  color: var(--t2);
}

/* Item card (list) */
.item-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.item-card:active { background: var(--bg); }

.item-thumb {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background: #f2f4f6;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }

.item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
}

.item-meta {
  font-size: 12px;
  color: var(--t2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 6px;
}

.item-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.item-price-main {
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
}

.item-price-ref {
  font-size: 12px;
  color: var(--t2);
}

.item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.item-deadline {
  font-size: 12px;
  color: var(--t2);
}

.item-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.item-badge.red { background: #fdedf0; color: var(--red); }
.item-badge.amber { background: #fef9ec; color: #b45309; }
.item-badge.gray { background: var(--bg); color: var(--t3); }
.item-badge.green { background: #e6f9f0; color: #0d9f6e; }

/* Load more */
.load-more-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 16px auto;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  text-align: center;
}

.empty-state {
  padding: 60px 16px;
  text-align: center;
  color: var(--t2);
  font-size: 15px;
}
.empty-state p { margin-top: 8px; font-size: 13px; }

/* ---- DETAIL ---- */
.detail-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 4px;
  height: 52px;
}

.detail-back {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 100%;
  color: var(--blue);
  font-size: 15px;
}

.detail-title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-right: 48px;
}

.detail-photo {
  width: 100%;
  aspect-ratio: 4/3;
  background: #f2f4f6;
  overflow: hidden;
}
.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detail-photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 13px;
  color: var(--t3);
}

.detail-section {
  background: var(--surface);
  margin-bottom: 8px;
  padding: 16px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
}

.detail-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--t1);
  margin-bottom: 6px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-tag {
  font-size: 12px;
  color: var(--t2);
  background: var(--bg);
  border-radius: 6px;
  padding: 3px 8px;
}

.detail-price-block { display: flex; flex-direction: column; gap: 10px; }

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.price-label { font-size: 14px; color: var(--t2); }

.price-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--t1);
}
.price-value.blue { color: var(--blue); }
.price-value.hidden { font-size: 14px; color: var(--t3); }

.price-sub {
  font-size: 12px;
  color: var(--t2);
  margin-top: 2px;
  text-align: right;
}

.similar-box {
  background: var(--blue-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
}
.similar-range { font-size: 15px; font-weight: 700; color: var(--t1); margin-bottom: 6px; }
.similar-level { font-size: 12px; color: var(--t2); }

.similar-examples {
  margin-top: 12px;
  border-top: 1px solid rgba(0,0,0,.07);
  padding-top: 10px;
}

.similar-ex-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--t2);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.similar-ex-row:last-child { border-bottom: none; }
.similar-ex-price { font-weight: 600; color: var(--t1); }

/* Detail spec table */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-row td {
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.spec-row:last-child td { border-bottom: none; }
.spec-label { color: var(--t2); width: 90px; }
.spec-value { color: var(--t1); font-weight: 500; }

/* Onbid link */
.onbid-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--blue);
  font-weight: 600;
  margin-top: 8px;
}

/* Disclaimer */
.disclaimer {
  font-size: 11px;
  color: var(--t3);
  line-height: 1.6;
  padding: 12px 16px;
  background: var(--surface);
  margin-bottom: 8px;
}

/* Fixed bottom action bar */
.detail-actions {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 50;
  display: flex;
  gap: 10px;
}
.btn-cal, .btn-alert-open {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-cal {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--t1);
}
.btn-cal:active { background: var(--border); }
.btn-alert-open { background: var(--blue); color: #fff; }
.btn-alert-open:active { background: var(--blue-dark); }

/* Bottom sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  z-index: 201;
  transition: transform .3s cubic-bezier(0.32, 0.72, 0, 1);
}
.bottom-sheet.open { transform: translateX(-50%) translateY(0); }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.sheet-heading { font-size: 17px; font-weight: 700; color: var(--t1); margin-bottom: 6px; }
.sheet-subtext { font-size: 13px; color: var(--t2); margin-bottom: 20px; }
.sheet-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 15px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 10px;
  text-align: left;
  transition: background .15s;
}
.sheet-option:last-of-type { margin-bottom: 0; }
.sheet-option:active { background: var(--border); }
.sheet-close {
  display: block;
  width: 100%;
  padding: 14px;
  background: none;
  font-size: 15px;
  color: var(--t3);
  margin-top: 10px;
  text-align: center;
}

/* Stub screen */
.stub-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  color: var(--t2);
  font-size: 15px;
}
.stub-icon { font-size: 48px; }
.stub-title { font-size: 18px; font-weight: 700; color: var(--t1); }

/* Cost calculator */
.cost-input-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cost-input-label { font-size: 14px; color: var(--t2); flex-shrink: 0; }
.cost-input {
  width: 90px; padding: 6px 8px; font-size: 16px; font-weight: 600;
  color: var(--t1); background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; text-align: right;
}
.cost-input:focus { outline: none; border-color: var(--blue); }
.cost-input-unit { font-size: 14px; color: var(--t2); }
.cost-table { width: 100%; border-collapse: collapse; }
.cost-row td { padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.cost-row:last-child td { border-bottom: none; }
.cost-label { color: var(--t2); }
.cost-value { color: var(--t1); font-weight: 500; text-align: right; }
.total-value { color: var(--blue); font-size: 17px; font-weight: 700; }
.cost-total-row td { border-top: 1.5px solid var(--border); border-bottom: none; padding-top: 10px; }
.cost-note { font-size: 12px; color: var(--t2); margin-top: 8px; }
.cost-disclaimer { font-size: 11px; color: var(--t3); line-height: 1.6; margin-top: 8px; }

/* Price drop badge */
.drop-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  background: #fdedf0;
  border-radius: 4px;
  padding: 1px 5px;
}
