/* SPDX-License-Identifier: Apache-2.0
   Copyright 2026 CLSOFTLAB (씨엘소프트랩), Dr. Lee Il-guk (이일국) */

:root {
  --bg: #fff5f8;
  --surface: #ffffff;
  --surface-2: #fdeef3;
  --text: #2a1f26;
  --muted: #7a6b72;
  --border: #f2d7e0;
  --accent: #e6437c;
  --accent-soft: #ffe0ec;
  --shadow: 0 6px 24px rgba(180, 70, 110, 0.12);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1418;
    --surface: #241a20;
    --surface-2: #2e2028;
    --text: #f3e9ee;
    --muted: #b39aa6;
    --border: #3a2b33;
    --accent: #ff6fa3;
    --accent-soft: #3d2530;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
p { margin: 0 0 .6em; }
button { font-family: inherit; cursor: pointer; }
img, svg { max-width: 100%; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 1.6rem; }
.brand strong { display: block; font-size: 1.1rem; }
.brand small { color: var(--muted); font-size: .75rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 999px; padding: 8px 14px; font-size: .9rem;
}
.cart-btn { position: relative; }
.badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 20px; height: 20px; padding: 0 5px;
  display: none; place-items: center;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: .72rem; font-weight: 700;
}
.badge.dark { position: static; display: inline-grid; vertical-align: middle; }

/* ---- Tabs ---- */
.tabs {
  position: sticky; top: 61px; z-index: 30;
  display: flex; gap: 4px; overflow-x: auto;
  padding: 8px 12px; background: var(--bg);
  border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch;
}
.tab-btn {
  flex: 0 0 auto; border: none; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-size: .92rem; font-weight: 600; white-space: nowrap;
}
.tab-btn.active { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.hero { padding: 12px 0 18px; }
.hero h1 { font-size: 1.5rem; }
.hero p { color: var(--muted); max-width: 640px; }

/* ---- Filters ---- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.filters input[type="search"] {
  flex: 1 1 200px; min-width: 140px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: .92rem;
}
.filters label { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.filters select {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 7px 9px; font-size: .88rem;
}
.price-filter { flex-direction: column; align-items: flex-start; gap: 2px; }
.result-count { color: var(--muted); font-size: .85rem; margin: 4px 2px 12px; }

/* ---- 오늘의 추천 (무인 on-load 다이제스트) ---- */
.daily-pick {
  background: var(--accent-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin: 0 0 16px;
}
.daily-pick h2 { margin: 0 0 6px; font-size: 1.05rem; }
.daily-pick h2 small { color: var(--muted); font-weight: 500; font-size: .78rem; }
.daily-pick .daily-pick-out {
  display: block; background: transparent; border: none; padding: 0; margin: 0; min-height: 1.2em;
}

/* ---- Grid & cards ---- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; transition: transform .15s;
}
.card:hover { transform: translateY(-3px); }
.wish {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  border: none; background: rgba(255,255,255,.85); color: #e6437c;
  width: 34px; height: 34px; border-radius: 999px; font-size: 1.1rem; line-height: 1;
}
.wish.on { background: var(--accent); color: #fff; }
.card-swatch {
  border: none; padding: 0; height: 120px; width: 100%;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, #fff));
  display: grid; place-items: center;
}
.mini-nails { width: 70%; max-width: 160px; }
.mini-nails svg { filter: drop-shadow(0 2px 3px rgba(0,0,0,.15)); }
.card-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-tags { display: flex; gap: 6px; }
.tag {
  font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.tag.ghost { background: var(--surface-2); color: var(--muted); }
.card-body h3 { font-size: 1rem; cursor: pointer; }
.card-body .brand { color: var(--muted); font-size: .78rem; margin: 0; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; }
.card-foot strong { font-size: 1.02rem; }
.card-actions { display: flex; gap: 6px; }

/* ---- Buttons ---- */
.btn {
  border: none; background: var(--accent); color: #fff;
  border-radius: 10px; padding: 10px 16px; font-size: .92rem; font-weight: 600;
}
.btn.small { padding: 7px 11px; font-size: .8rem; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.empty { color: var(--muted); padding: 30px 10px; text-align: center; grid-column: 1 / -1; }

/* ---- Preview ---- */
.preview-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.preview-stage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: grid; place-items: center; box-shadow: var(--shadow);
}
.preview-stage svg { max-height: 360px; }
.preview-current { color: var(--muted); }
.chips-label { font-size: .82rem; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.style-toggle { display: flex; flex-wrap: wrap; gap: 6px; }
.style-toggle button, .pill {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 8px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.style-toggle button.on, .pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.shade-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.shade-chip {
  width: 34px; height: 34px; border-radius: 999px; border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border); padding: 0;
}
.shade-chip.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.recommend-copy { color: var(--accent); font-weight: 600; margin: 12px 0; }

/* ---- AI assistant ---- */
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.ai-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.ai-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.ai-picker label { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.ai-picker select {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 7px 10px; font-size: .85rem;
}
.ai-log {
  display: flex; flex-direction: column; gap: 8px;
  min-height: 120px; max-height: 320px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.ai-bubble {
  max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: .9rem;
  white-space: pre-wrap; word-break: break-word;
}
.ai-bubble.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-form { display: flex; gap: 8px; }
.ai-form input {
  flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: .9rem;
}
.ai-out {
  display: none; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-top: 10px; font-size: .9rem;
}
.ai-out.show { display: block; }
.ai-out.streaming::after, .ai-bubble.streaming::after {
  content: '▍'; color: var(--accent); animation: ai-blink 1s steps(2) infinite;
}
@keyframes ai-blink { 50% { opacity: 0; } }

/* ---- Plans ---- */
.plans-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.plan {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.plan.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset, var(--shadow); }
.plan-price { font-size: 1.5rem; font-weight: 800; }
.plan-price span { font-size: .8rem; color: var(--muted); font-weight: 500; }
.plan-desc { color: var(--muted); font-size: .88rem; }
.plan ul { margin: 6px 0; padding-left: 18px; color: var(--muted); font-size: .85rem; }
.plan-items { font-weight: 600; margin-top: auto; }

/* ---- Cart drawer ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 45; }
.overlay.show { opacity: 1; pointer-events: auto; }
.cart-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(380px, 90vw);
  background: var(--surface); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .25s; z-index: 50;
  display: flex; flex-direction: column;
}
.cart-drawer.open { transform: translateX(0); }
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.cart-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.cart-line { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cart-sw { width: 34px; height: 34px; border-radius: 8px; }
.cart-line-info strong { display: block; font-size: .9rem; }
.cart-line-info small { color: var(--muted); }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.rm { border: none; background: transparent; color: var(--muted); font-size: 1rem; }
.cart-foot { padding: 16px; border-top: 1px solid var(--border); }
.cart-total-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 1.05rem; }
.demo-note { color: var(--muted); font-size: .75rem; margin: 8px 0 0; }

/* ---- Modal ---- */
.modal {
  border: none; border-radius: var(--radius); padding: 0; width: min(880px, 94vw);
  max-height: 92vh; background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal-close { position: absolute; top: 10px; right: 10px; z-index: 3; border: none; background: var(--surface-2); color: var(--text); width: 34px; height: 34px; border-radius: 999px; }
#modal-body { max-height: 92vh; overflow-y: auto; padding: 20px; }
.detail { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; }
.detail-hand { background: var(--surface-2); border-radius: var(--radius); padding: 12px; display: grid; place-items: center; }
.detail-hand svg { max-height: 280px; }
.swatch-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.swatch-big { width: 48px; height: 48px; border-radius: 12px; box-shadow: 0 0 0 1px var(--border); }
.detail-price { font-size: 1.4rem; display: block; margin: 10px 0; }
.detail-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.detail-info h4 { margin-top: 16px; }
.components, .steps, .reviews { padding-left: 18px; color: var(--text); }
.reviews { list-style: none; padding-left: 0; }
.reviews li { background: var(--surface-2); border-radius: 10px; padding: 10px; margin-bottom: 8px; font-size: .88rem; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Footer ---- */
.site-foot { max-width: 1100px; margin: 30px auto 0; padding: 24px 16px; border-top: 1px solid var(--border); color: var(--muted); }
.site-foot .small { font-size: .75rem; }

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .preview-wrap { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.3rem; }
  .tabs { top: 61px; }
}
