/* 만나보자 웹 — 모바일 우선, 화이트 미니멀 테마 */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;       /* slate-50 */
  --surface-hover: #F1F5F9;     /* slate-100 */
  --border: #E2E8F0;            /* slate-200 */
  --border-strong: #CBD5E1;     /* slate-300 */
  --text: #0F172A;              /* slate-900 */
  --text-dim: #475569;           /* slate-600 */
  --text-muted: #94A3B8;         /* slate-400 */
  --primary: #0F172A;           /* slate-900 — 버튼/내 선택 */
  --primary-hover: #1E293B;     /* slate-800 */
  --primary-soft: #F1F5F9;
  --accent: #4F46E5;             /* indigo-600 — 다른 사람 선택 틴트 */
  --accent-light: #C7D2FE;       /* indigo-200 */
  --accent-soft: #EEF2FF;        /* indigo-50 */
  --success: #059669;            /* emerald-600 */
  --success-soft: #ECFDF5;       /* emerald-50 */
  --danger: #DC2626;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: var(--text);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input {
  font-family: inherit;
}

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-name {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.brand-sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
  letter-spacing: 0.2px;
}
.store-btn {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s;
}
.store-btn:hover { background: var(--surface-hover); }

/* ── Layout ────────────────────────────────────────────── */
main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}
.view { display: flex; flex-direction: column; gap: 18px; }

/* ── Loading ───────────────────────────────────────────── */
.loading {
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--surface-alt);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ── Code entry view ───────────────────────────────────── */
.hero {
  text-align: center;
  padding: 36px 8px 20px;
}
.hero h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text);
}
.hero p {
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 14px;
}

.code-input-row {
  display: flex;
  gap: 8px;
}
.code-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.code-input::placeholder { color: var(--text-muted); font-weight: 500; }
.code-input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06); }

.btn {
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 10px;
  min-width: 80px;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-hover); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-outline:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { font-size: 13px; padding: 9px 14px; min-width: auto; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* ── Nickname prompt ───────────────────────────────────── */
.nickname-card label {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}
.text-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06); }

/* ── Invite header ─────────────────────────────────────── */
.invite-head {
  text-align: center;
  padding: 4px 0 4px;
}
.invite-head h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.code-display {
  margin-top: 4px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}
.code-display .label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.code-display .code {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 6px;
  margin-top: 6px;
  cursor: pointer;
}
.code-display .copy-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Result summary ────────────────────────────────────── */
.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.result-card h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.result-empty { color: var(--text-muted); font-size: 13px; }
.result-line { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.big-count { color: var(--success); font-size: 22px; font-weight: 700; margin: 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.chip-full { background: var(--success-soft); color: var(--success); border: 1px solid #A7F3D0; }
.chip-partial { background: var(--surface-alt); color: var(--text-dim); border: 1px solid var(--border); }

/* ── Calendar ──────────────────────────────────────────── */
.calendar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.cal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 12px;
}
.cal-nav {
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 6px;
  transition: background 0.15s;
}
.cal-nav:hover { background: var(--surface-alt); color: var(--text); }
.cal-nav[disabled] { color: var(--text-muted); cursor: not-allowed; }
.cal-nav[disabled]:hover { background: transparent; color: var(--text-muted); }
.cal-month {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 8px 0 6px;
  letter-spacing: 0.3px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  position: relative;
  user-select: none;
  transition: background 0.12s;
  cursor: pointer;
}
.cal-cell:hover { background: var(--surface-alt); }
.cal-cell.muted { color: var(--text-muted); cursor: default; opacity: 0.5; }
.cal-cell.muted:hover { background: transparent; }
.cal-cell.today {
  color: var(--accent);
  font-weight: 700;
}
.cal-cell.selected {
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
}
.cal-cell.selected:hover { background: var(--primary-hover); }
.cal-cell.selected.today { color: #FFFFFF; }

/* 다른 사람이 선택한 셀 (count 배지 + 인디고 틴트) */
.cal-cell .others-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  letter-spacing: 0;
}
.cal-cell.selected .others-badge {
  background: #FFFFFF;
  color: var(--primary);
}

.cal-helper {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.cal-helper .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
}
.cal-helper .swatch.swatch-mine { background: var(--primary); border-radius: 3px; }
.cal-helper .swatch.swatch-others { background: var(--accent); border-radius: 50%; }

/* ── Save bar (sticky bottom when dirty) ───────────────── */
.save-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 8px;
}

/* ── Participants list ─────────────────────────────────── */
.participants {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.participants h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.p-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.p-name { font-size: 14px; font-weight: 600; color: var(--text); }
.p-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; font-weight: 500; }
.p-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.p-badge.host { background: var(--accent-soft); color: var(--accent); }
.p-badge.you { background: var(--primary-soft); color: var(--text); }

/* ── Footer ────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 32px 16px 28px;
  color: var(--text-muted);
  font-size: 12px;
}
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--text); }
.footer .dot { margin: 0 8px; color: var(--text-muted); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 480px) {
  body { font-size: 14px; }

  .topbar { padding: 12px 16px; }
  .brand-name { font-size: 16px; }
  .brand-sub { font-size: 10px; }
  .store-btn { font-size: 11px; padding: 7px 11px; }

  main { padding: 20px 16px 32px; }

  .hero { padding: 24px 4px 16px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 13px; }

  .code-input {
    font-size: 18px;
    letter-spacing: 3px;
    padding: 13px 12px;
  }
  .btn { font-size: 14px; padding: 13px 14px; min-width: 72px; }

  .invite-head h2 { font-size: 20px; }
  .code-display { padding: 14px; }
  .code-display .code { font-size: 26px; letter-spacing: 5px; }

  .result-card, .calendar-wrap, .card { padding: 16px; }

  .cal-cell { font-size: 13px; }
  .cal-dow { font-size: 11px; padding: 6px 0 4px; }
  .cal-month { font-size: 14px; }

  .chip { padding: 5px 9px; font-size: 12px; }

  .p-row { padding: 11px 13px; }
  .p-name { font-size: 13px; }
}

@media (max-width: 360px) {
  .brand-sub { display: none; }
  .hero h1 { font-size: 20px; }
  .code-input { font-size: 16px; letter-spacing: 2px; }
  .code-display .code { font-size: 22px; letter-spacing: 4px; }
}

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #FFFFFF;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
