/*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright 2026 CLSOFTLAB (씨엘소프트랩), Dr. Lee Il-guk (이일국)
 * styles.css — 모바일 우선, 라이트/다크 테마 토큰 기반.
 */

:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #f1eee9;
  --text: #201c2b;
  --text-dim: #6c6577;
  --border: #e3ddd4;
  --accent: #7c6cf0;
  --accent-2: #d98cc0;
  --accent-ink: #ffffff;
  --good: #3aa76d;
  --warn: #c9822a;
  --danger: #d1495b;
  --shadow: 0 6px 24px rgba(40, 30, 60, 0.08);
  --radius: 14px;
  --maxw: 1120px;
  --font: "Pretendard", system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
}

:root[data-theme="dark"],
:root[data-theme="auto"] {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #17151d;
    --surface: #201d29;
    --surface-2: #2a2635;
    --text: #ece8f2;
    --text-dim: #a49db6;
    --border: #342f40;
    --accent: #9a8cff;
    --accent-2: #e69fd0;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --bg: #17151d;
  --surface: #201d29;
  --surface-2: #2a2635;
  --text: #ece8f2;
  --text-dim: #a49db6;
  --border: #342f40;
  --accent: #9a8cff;
  --accent-2: #e69fd0;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration: none;
}
img,
svg {
  max-width: 100%;
}
h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5em;
}

.skip-link {
  position: absolute;
  left: -999px;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 1rem;
  border-radius: 8px;
}

/* ── Topbar ─────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
}
.brand-name {
  display: flex;
  flex-direction: column;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.brand-name small {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0;
}
.global-nav {
  display: none;
  gap: 0.25rem;
  margin-left: 1rem;
  flex: 1;
}
.global-nav a {
  padding: 0.4rem 0.7rem;
  border-radius: 9px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.92rem;
}
.global-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.global-nav a.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.only-mobile {
  display: inline-flex;
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.mobile-nav a {
  padding: 0.7rem 0.5rem;
  border-radius: 8px;
  font-weight: 600;
}
.mobile-nav a.active {
  color: var(--accent);
}

/* ── Layout ─────────────────────────────── */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  outline: none;
}
.section-head {
  margin: 1.5rem 0 1rem;
}
.section-head p {
  color: var(--text-dim);
  margin: 0.2rem 0 0;
}
.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .grid.cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 900px) {
  .grid.cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .global-nav {
    display: flex;
  }
  .only-mobile {
    display: none;
  }
  .mobile-nav {
    display: none !important;
  }
}

/* ── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.ghost {
  background: transparent;
}
.btn.block {
  width: 100%;
}
.btn.sm {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

/* ── Cards ──────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-pad {
  padding: 1.1rem;
}
.product-card .art {
  display: block;
  background: var(--surface-2);
}
.product-card .art svg {
  width: 100%;
  height: auto;
  display: block;
}
.product-card .meta {
  padding: 0.85rem 1rem 1rem;
}
.product-card h3 {
  font-size: 1.02rem;
  margin: 0.1rem 0 0.2rem;
}
.muted {
  color: var(--text-dim);
  font-size: 0.85rem;
}
.price {
  font-weight: 800;
  font-size: 1.05rem;
}
.tag {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  margin: 0 0.25rem 0.25rem 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
}
.tag.accent {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good);
  font-weight: 800;
  font-size: 0.8rem;
}
.wish-toggle {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-dim);
}
.wish-toggle.on {
  color: var(--danger);
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.between {
  justify-content: space-between;
}
.wrap {
  flex-wrap: wrap;
}

/* ── Hero ───────────────────────────────── */
.hero {
  display: grid;
  gap: 1.2rem;
  padding: 1.5rem;
  border-radius: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), color-mix(in srgb, var(--accent-2) 22%, var(--surface)));
  border: 1px solid var(--border);
}
.hero h1 {
  font-size: 1.7rem;
}
@media (min-width: 760px) {
  .hero {
    grid-template-columns: 1.3fr 1fr;
    align-items: center;
  }
  .hero h1 {
    font-size: 2.2rem;
  }
}

/* ── Survey ─────────────────────────────── */
.survey-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.opt-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-top: 0.8rem;
}
.opt {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.opt small {
  color: var(--text-dim);
  font-size: 0.75rem;
}
.opt.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.scale {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
}
.scale button {
  flex: 1;
  min-width: 56px;
  padding: 0.8rem 0.3rem;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.scale button.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-weight: 800;
}
.progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.8rem 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

/* ── Filters ────────────────────────────── */
.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
}
.input,
.select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input {
  flex: 1;
  min-width: 160px;
}
.chip {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.chip.on {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* ── Detail / notes ─────────────────────── */
.detail {
  display: grid;
  gap: 1.4rem;
}
@media (min-width: 760px) {
  .detail {
    grid-template-columns: 1fr 1.1fr;
    align-items: start;
  }
}
.notes {
  display: grid;
  gap: 0.6rem;
}
.note-row {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface-2);
  border-radius: 10px;
}
.note-row b {
  min-width: 3.2rem;
  color: var(--accent);
}

/* ── Tables (responsive overflow) ───────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}
th,
td {
  padding: 0.7rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
th {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Plans ──────────────────────────────── */
.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.plan.recommended {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent), var(--shadow);
}
.plan .ribbon {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.plan ul {
  margin: 0.4rem 0;
  padding-left: 1.1rem;
}
.plan li {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

/* ── Calendar ───────────────────────────── */
.timeline {
  display: grid;
  gap: 0.6rem;
}
.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.timeline-item .dot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-weight: 800;
}

/* ── AI panel & chatbot ─────────────────── */
.ai-fab {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 50;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.ai-panel {
  position: fixed;
  z-index: 60;
  inset: auto 0 0 0;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
}
@media (min-width: 640px) {
  .ai-panel {
    inset: auto 18px 18px auto;
    width: 400px;
    max-height: 72vh;
    border: 1px solid var(--border);
    border-radius: 16px;
  }
}
.ai-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}
.ai-tabs {
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem 0.7rem 0;
  flex-wrap: wrap;
}
.ai-tabs button {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px 999px 0 0;
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
}
.ai-tabs button.on {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}
.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.bubble {
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  white-space: pre-wrap;
  font-size: 0.9rem;
}
.bubble.ai {
  background: var(--surface-2);
  border-bottom-left-radius: 3px;
}
.bubble.me {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.ai-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid var(--border);
}
.ai-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0 1rem 0.6rem;
}

/* ── Toast ──────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

/* ── Footer ─────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 2rem;
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.4rem 1rem;
  color: var(--text-dim);
  font-size: 0.82rem;
}
.footer-demo {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  color: var(--text);
}
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.notice {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}
[hidden] {
  display: none !important;
}
