:root {
  --coral: #ff7b7b;
  --coral-d: #f06464;
  --ink: #2b2433;
  --ink-2: #6b6474;
  --paper: #fff8f3;
  --card: #ffffff;
  --line: #efe2d9;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --sheet-h: 150px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, a.primary { font: inherit; }
button, input { color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible + span, .sw:focus-within { outline: 3px solid var(--coral); outline-offset: 2px; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

/* ---------- 머리 ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center;
  padding: calc(var(--safe-t) + 12px) 16px 8px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand .name { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.brand small { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.dot { width: 22px; height: 22px; border-radius: 6px; background: var(--coral); box-shadow: 2px 2px 0 var(--ink); position: relative; flex: none; }
.dot::before, .dot::after { content: ""; position: absolute; top: 7px; width: 3px; height: 5px; background: var(--ink); border-radius: 1px; }
.dot::before { left: 6px; } .dot::after { right: 6px; }
.pill { border: 1.5px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.pill:active { transform: scale(.97); }
body.profile .top { visibility: hidden; }

/* ---------- 첫 화면 ---------- */
.empty { position: fixed; left: 16px; right: 16px; top: calc(var(--safe-t) + 84px); text-align: center; pointer-events: none; z-index: 1; }
.empty .big { font-size: clamp(26px, 7vw, 36px); font-weight: 800; line-height: 1.28; margin: 0 0 8px; letter-spacing: -0.03em; }
.empty em { font-style: normal; color: var(--coral); }
.empty .small { margin: 0; color: var(--ink-2); font-size: 15px; }

/* ---------- 상태 알약 ---------- */
.status { position: fixed; z-index: 3; top: calc(var(--safe-t) + 68px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  display: flex; gap: 8px; align-items: center; white-space: nowrap; box-shadow: 0 6px 18px rgba(43, 36, 51, .18); }
.spinner { width: 14px; height: 14px; border: 2px solid #fff6; border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ring { position: fixed; z-index: 1; pointer-events: none; border-radius: 50%; box-shadow: 0 0 0 9999px rgba(43, 36, 51, .5); outline: 2px solid rgba(255, 255, 255, .9); }

/* ---------- 아래 패널 ---------- */
.sheet { position: fixed; z-index: 2; left: 0; right: 0; bottom: 0; padding: 28px 16px calc(var(--safe-b) + 14px);
  background: linear-gradient(to top, var(--paper) 72%, rgba(255, 248, 243, 0)); }
body.profile .sheet { background: var(--paper); padding-top: 14px; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 24px rgba(43, 36, 51, .12); }
.sheet > div { max-width: 520px; margin: 0 auto; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px; margin: 0 -16px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--line); background: var(--card); padding: 7px 13px; border-radius: 999px; font-size: 14px; }
.chip:active { transform: scale(.97); }
body.busy .chips { opacity: .4; pointer-events: none; }

.ask { display: flex; gap: 8px; background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 6px 6px 6px 10px; box-shadow: 3px 3px 0 var(--ink); transition: box-shadow .15s; }
.ask:focus-within { box-shadow: 3px 3px 0 var(--coral); }
.ask input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 16px; padding: 8px 4px; background: transparent; }
.ask input::placeholder { color: #a39aa8; }
.ask input:focus-visible { outline: none; }
.ask button { flex: none; border: 0; background: var(--coral); color: #fff; font-weight: 700; font-size: 15px; border-radius: 11px; padding: 0 18px; min-height: 42px; }
.ask button:active { background: var(--coral-d); }
.ask button:disabled { opacity: .5; cursor: default; }

.after, .row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.primary { border: 0; background: var(--ink); color: #fff; font-weight: 700; padding: 0 16px; min-height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: 15px; }
.primary:active, .ghost:active { transform: scale(.98); }
.after .primary { flex: 1; }
.ghost { border: 1.5px solid var(--line); background: var(--card); padding: 0 16px; min-height: 46px; border-radius: 12px; font-size: 15px; font-weight: 600; }
.grow { flex: 1; }

/* ---------- 프로필 패널 ---------- */
.hint { color: var(--ink-2); font-size: 13px; margin: 0 0 10px; text-align: center; }
.swatches { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; max-width: 420px; margin: 0 auto; }
.sw { aspect-ratio: 1; width: 100%; border-radius: 50%; border: 1.5px solid rgba(43, 36, 51, .14); padding: 0; position: relative; }
.sw.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.sw.custom { background: conic-gradient(#ff7b7b, #ffd84a, #7fd8be, #8ec5ff, #c3a6ff, #ff7b7b); overflow: hidden; cursor: pointer; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.toggles { justify-content: center; }
.toggle { display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); font-size: 14px; font-weight: 600; white-space: nowrap; }
.toggle span::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid #c9bfc5; background: #fff; }
.toggle input:checked + span { border-color: var(--ink); }
.toggle input:checked + span::before { background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat; border-color: var(--ink); }

/* ---------- 창 ---------- */
.dlg { border: 0; border-radius: 22px; padding: 18px; width: min(92vw, 420px); max-height: 86vh; background: var(--paper); color: var(--ink); }
.dlg::backdrop { background: rgba(43, 36, 51, .5); }
#saveDlg img { width: 100%; border-radius: 50%; display: block; margin: 0 auto 12px; aspect-ratio: 1; box-shadow: 0 6px 20px rgba(43, 36, 51, .15); }
.dlg h2 { margin: 2px 0 12px; font-size: 18px; }
.recent { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 52vh; overflow-y: auto; margin-bottom: 10px; }
.recent button { min-width: 0; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 4px 4px 0; font-size: 12px; }
.recent img { width: 100%; aspect-ratio: 1; display: block; border-radius: 10px; object-fit: cover; background: var(--paper); }
.recent span { display: block; padding: 5px 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .none { grid-column: 1 / -1; padding: 28px 0; }

.toast { position: fixed; z-index: 4; left: 50%; bottom: calc(var(--sheet-h) + 12px); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 6px 18px rgba(43, 36, 51, .2); }

@media (min-width: 720px) {
  .empty { top: calc(var(--safe-t) + 96px); }
  .sheet { padding-bottom: calc(var(--safe-b) + 24px); }
}
