:root {
  --bg: #fff8f5;
  --surface: #ffffff;
  --surface-2: #fff0eb;
  --text: #2a2230;
  --muted: #8c8191;
  --line: #f1e3de;
  --primary: #ff5e7e;
  --primary-2: #ff9a62;
  --primary-soft: #ffe6ea;
  --good: #12925a;
  --good-bg: #e7f7ef;
  --warn: #c26a00;
  --warn-bg: #fff3e0;
  --plan: #6d4ae0;
  --plan-bg: #f1ecff;
  --info: #2f6fd6;
  --info-bg: #eaf2ff;
  --danger: #d6334f;
  --shadow: 0 8px 28px rgba(90, 40, 50, 0.08);
  --radius: 20px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131a;
    --surface: #221c26;
    --surface-2: #2c2431;
    --text: #f4eef6;
    --muted: #a99dae;
    --line: #3a3040;
    --primary-soft: #45222e;
    --good: #4ade9b;
    --good-bg: #173326;
    --warn: #ffb74d;
    --warn-bg: #3a2a14;
    --plan: #b39cff;
    --plan-bg: #2b2245;
    --info: #8db6ff;
    --info-bg: #1c2a44;
    --danger: #ff7a90;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, p, figure, pre { margin: 0; }
img, video { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.prewrap { white-space: pre-wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 레이아웃 */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.page.wide { max-width: 980px; }
.loading { min-height: 60vh; display: grid; place-items: center; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 14px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab.active { color: var(--primary); background: var(--primary-soft); }
.tab-icon { position: relative; font-size: 20px; line-height: 1.1; }
.tab-badge { position: absolute; top: -6px; right: -14px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 10px; line-height: 18px; text-align: center; }

.page-head { display: flex; align-items: center; gap: 10px; }
.page-head-text { flex: 1; min-width: 0; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.back { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-size: 24px; line-height: 1; padding-bottom: 3px; }

.hello { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 4px 2px; }
.hello h1 { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.35; }
.hello-sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.icon-link { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-size: 18px; }

.section-title { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px 0; }
.section-title b { font-size: 16px; }
.section-title a { color: var(--primary); font-size: 13px; font-weight: 700; }

/* ---------- 카드 · 버튼 · 폼 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.card-title { font-weight: 800; font-size: 15px; }
.note { color: var(--muted); font-size: 13px; text-align: center; padding: 2px 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: transform 0.1s ease, opacity 0.2s;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; box-shadow: 0 6px 16px rgba(255, 94, 126, 0.25); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.white { background: #fff; color: #2a2230; }
.btn.danger { color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 11px; }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 700; font-size: 13.5px; padding: 4px 0; cursor: pointer; align-self: flex-start; }
.icon-btn { width: 34px; height: 34px; flex: none; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 14px; }
.icon-btn.sm { width: 28px; height: 28px; font-size: 13px; }
.icon-btn.ghost { visibility: hidden; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
input:not([type='checkbox']), textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}
select {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: var(--surface); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.link { color: var(--primary); font-weight: 700; }
textarea { resize: vertical; min-height: 80px; }
input[type='date'] { min-height: 48px; }
.form-error { color: var(--danger); font-size: 13.5px; font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.gym { background: var(--info-bg); color: var(--info); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.pink { background: var(--primary-soft); color: var(--primary); margin-left: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chips.static .chip { padding: 4px 11px; font-size: 13px; cursor: default; }

/* ---------- 로그인 */
.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 20px; max-width: 420px; margin: 0 auto; padding: 32px 16px; }
.brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.brand img { border-radius: 20px; box-shadow: 0 10px 30px rgba(255, 94, 126, 0.3); }
.brand h1 { font-size: 28px; font-weight: 900; letter-spacing: -0.03em; margin-top: 8px; }
.brand p { color: var(--muted); font-weight: 600; }
.auth-card { gap: 14px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 홈 */
.notice { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--info-bg); color: var(--info); }
.notice-icon { font-size: 24px; }
.notice-text { flex: 1; display: flex; flex-direction: column; }
.notice-text span { font-size: 13px; opacity: 0.9; }
.chev { color: var(--muted); font-size: 22px; line-height: 1; flex: none; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- 초대 */
.invite-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px; border-radius: var(--radius); color: #fff; background: linear-gradient(135deg, var(--primary-2), var(--primary)); box-shadow: 0 12px 30px rgba(255, 94, 126, 0.3); }
.invite-card b { font-size: 18px; }
.invite-card span:last-child { font-size: 13px; opacity: 0.92; }
.invite-emoji { font-size: 34px; }
.invite-row { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.invite-row:last-child { border-bottom: 0; }
.invite-row .badge { vertical-align: 2px; }
.invite-actions { display: flex; gap: 6px; flex: none; }

.hero {
  border-radius: 26px;
  padding: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--c2) 35%, transparent);
  display: flex; flex-direction: column; gap: 14px;
}
.hero-top { display: flex; gap: 14px; align-items: center; }
.hero .portrait { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55); background: rgba(255, 255, 255, 0.22); }
.hero-info { display: flex; flex-direction: column; min-width: 0; }
.hero-kicker { font-size: 11.5px; font-weight: 800; opacity: 0.85; letter-spacing: 0.04em; }
.hero-name { font-size: 21px; font-weight: 800; }
.hero-tag { font-size: 13px; opacity: 0.92; }
.hero .meter-top { color: #fff; }
.hero .meter-top .muted { color: rgba(255, 255, 255, 0.8); }
.hero .meter-bar { background: rgba(255, 255, 255, 0.3); }
.hero .meter-bar i { background: #fff; }
.hero-story { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; background: rgba(255, 255, 255, 0.16); border-radius: 14px; padding: 10px 12px; }
.hero-story span:first-child { font-weight: 800; }

.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; font-weight: 700; }
.meter-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary-2), var(--primary)); transition: width 0.4s ease; }

.pick-card { align-items: center; text-align: center; }
.pick-emoji { font-size: 40px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.stat-icon { font-size: 20px; }
.stat b { font-size: 18px; font-weight: 800; }
.stat span:last-child { font-size: 12px; color: var(--muted); font-weight: 600; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.week-day i { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-style: normal; font-weight: 900; color: #fff; }
.week-day.on i { background: linear-gradient(135deg, var(--primary-2), var(--primary)); }
.week-day.today span { color: var(--primary); }
.week-day.today i { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary-soft); }

.cta { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 2px dashed color-mix(in srgb, var(--primary) 50%, var(--line)); }
.cta-emoji { font-size: 30px; }
.cta-text { flex: 1; display: flex; flex-direction: column; }
.cta-text b { font-size: 16px; }
.cta-text span { font-size: 13px; color: var(--muted); }
.done-card { background: var(--good-bg); border-color: transparent; box-shadow: none; }
.done-card b { color: var(--good); }

/* ---------- 리스트 */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--surface-2); }
.list-item.unread { background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.li-date { width: 46px; height: 50px; flex: none; border-radius: 14px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.li-date b { font-size: 18px; }
.li-date span { font-size: 11px; color: var(--muted); font-weight: 700; }
.li-icon { width: 44px; height: 44px; flex: none; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-size: 20px; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.li-main > b { font-size: 15px; }
.li-main > span { font-size: 13px; }
.li-sub { font-size: 12px; color: var(--muted); }
.li-tags { display: flex; gap: 6px; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; }

.empty { text-align: center; padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { color: var(--text); font-size: 16px; }
.empty-emoji { font-size: 34px; }

/* ---------- 캐릭터 */
.portrait {
  position: relative;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: linear-gradient(135deg, var(--c1, #ccc), var(--c2, #999));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  user-select: none;
}
.portrait.none { background: var(--surface-2); color: var(--muted); text-shadow: none; font-size: 16px; }
.portrait-mood { position: absolute; right: -0.15em; bottom: -0.15em; font-size: 0.55em; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2)); text-shadow: none; }

.char-list { display: grid; gap: 14px; }
.char-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.char-card.main { border-color: color-mix(in srgb, var(--c2) 55%, var(--line)); box-shadow: 0 10px 30px color-mix(in srgb, var(--c2) 25%, transparent); }
.char-band { height: 96px; position: relative; background: linear-gradient(135deg, var(--c1), var(--c2)); display: flex; align-items: flex-end; padding: 0 16px; }
.char-band .portrait { transform: translateY(36px); box-shadow: 0 0 0 4px var(--surface); }
.char-main-badge { position: absolute; top: 12px; right: 12px; background: rgba(255, 255, 255, 0.92); color: var(--c2); font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px; }
.char-body { padding: 44px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.char-name { display: flex; align-items: center; gap: 6px; font-size: 19px; }
.char-role { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.char-tag { font-weight: 700; }
.char-intro { font-size: 14px; color: var(--muted); }
.char-meta { display: flex; gap: 12px; font-size: 13px; font-weight: 700; margin-top: 4px; }
.char-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.char-actions .btn:only-child { grid-column: 1 / -1; }
.char-card .btn.primary { background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: none; }

/* ---------- 채팅 (스토리) */
.chat-page { height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; background: var(--bg); }
.stage {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 12px 14px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff;
  flex: none;
}
.stage-btn { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.2); font-size: 22px; line-height: 1; }
.stage-portrait { position: relative; flex: none; }
.stage-portrait .portrait { background: rgba(255, 255, 255, 0.22); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55); }
.stage-mood { position: absolute; right: -8px; bottom: -6px; font-size: 24px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.stage-mood.pop { animation: pop 0.35s ease; }
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.stage-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.stage-name { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.stage-main { font-size: 11px; font-weight: 800; background: rgba(255, 255, 255, 0.25); padding: 2px 8px; border-radius: 99px; }
.stage .meter-top { color: #fff; font-size: 11.5px; white-space: nowrap; }
.stage .meter-top .muted { display: none; }
.stage .meter-bar { background: rgba(255, 255, 255, 0.3); height: 6px; }
.stage .meter-bar i { background: #fff; }

.chat-list { flex: 1; overflow-y: auto; padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { display: flex; gap: 8px; align-items: flex-end; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg .bubble { padding: 10px 14px; border-radius: 18px; max-width: 78%; white-space: pre-wrap; font-size: 15px; }
.msg.char .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.me { justify-content: flex-end; }
.msg.me .bubble { background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; border-bottom-right-radius: 6px; }
.msg.narr { justify-content: center; text-align: center; color: var(--muted); font-size: 13.5px; font-style: italic; padding: 2px 22px; }
.msg.system { justify-content: center; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; text-align: center; }
.msg.system span { background: var(--surface-2); padding: 6px 12px; border-radius: 99px; }
.msg.system a { color: var(--primary); font-weight: 800; }
.msg.system.gain span { background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.typing .bubble { display: flex; gap: 4px; padding: 14px 16px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: 0.35; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 50% { opacity: 1; transform: translateY(-2px); } }
.chat-divider { text-align: center; margin: 12px 0 4px; }
.chat-divider span { display: inline-block; font-size: 12px; font-weight: 800; color: var(--c2); background: var(--surface); border: 1px solid var(--line); padding: 5px 14px; border-radius: 99px; }
.chat-empty { margin: auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px; color: var(--muted); }
.chat-empty b { color: var(--text); font-size: 20px; margin-top: 8px; }
.chat-empty-role { font-size: 13px; font-weight: 700; }
.chat-bar { flex: none; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.chat-bar .btn.primary { background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: none; }
.bar-note { text-align: center; color: var(--muted); font-size: 13px; padding: 8px; }
.bar-sub { text-align: center; color: var(--muted); font-size: 12px; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choices-label { font-size: 12px; color: var(--muted); text-align: center; font-weight: 700; }
.choice { text-align: left; padding: 13px 16px; border-radius: 14px; border: 1.5px solid color-mix(in srgb, var(--c2) 45%, var(--line)); background: var(--surface); font-weight: 700; font-size: 15px; cursor: pointer; transition: transform 0.1s; animation: rise 0.25s ease; }
.choice:active { transform: scale(0.98); background: var(--surface-2); }
.locked { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.locked-title { font-weight: 800; }
.locked p { color: var(--muted); font-size: 13.5px; }

/* ---------- 운동 기록 */
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex-card { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.ex-head { display: flex; gap: 8px; align-items: center; }
.ex-name { font-weight: 700; }
.sets { display: flex; flex-direction: column; gap: 6px; }
.set-row { display: grid; grid-template-columns: 44px 1fr auto 1fr auto 28px; gap: 6px; align-items: center; }
.set-row input { padding: 9px 10px; text-align: center; font-size: 16px; min-width: 0; }
.set-no { font-size: 12px; font-weight: 800; color: var(--muted); }
.unit { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.cond { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cond-btn { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 8px 0; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.cond-btn span { font-size: 24px; }
.cond-btn small { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.cond-btn.on { border-color: var(--primary); background: var(--primary-soft); }
.media-up { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; border-style: dashed; cursor: pointer; color: var(--muted); font-weight: 700; }
.thumb.add span { font-size: 26px; line-height: 1; }
.thumb.failed { outline: 2px solid var(--danger); }
.thumb-kind { position: absolute; left: 6px; top: 6px; font-size: 14px; }
.thumb-ok { position: absolute; left: 6px; bottom: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #fff; font-size: 12px; display: grid; place-items: center; font-weight: 900; }
.thumb-fail { position: absolute; left: 6px; bottom: 6px; background: var(--danger); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; font-weight: 800; }
.thumb-bar { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 6px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.thumb-bar i { display: block; height: 100%; background: #fff; transition: width 0.2s; }
.thumb-del { position: absolute; right: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 11px; cursor: pointer; }
.gym-card { background: var(--info-bg); border-color: transparent; box-shadow: none; }
.code-input { text-align: center; font-size: 26px !important; font-weight: 800; letter-spacing: 0.5em; padding-left: calc(14px + 0.5em) !important; }

.log-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.log-date { font-size: 18px; }
.log-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }
.ex-view { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.ex-view:first-of-type { border-top: 0; padding-top: 0; }
.set-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.set-pill { font-size: 13px; background: var(--surface-2); padding: 4px 10px; border-radius: 99px; font-weight: 600; }
.media-grid { display: grid; gap: 10px; }
.media-grid video, .media-grid img { width: 100%; border-radius: 14px; background: #000; max-height: 70vh; display: block; }
.media-grid img { background: none; }

/* ---------- 결과 · 모달 · 토스트 */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 10, 20, 0.5); display: flex; align-items: flex-end; justify-content: center; padding: 16px; animation: fade 0.2s ease; overflow-y: auto; }
@media (min-width: 640px) { .modal { align-items: center; } }
@keyframes fade { from { opacity: 0; } }
.modal-box { position: relative; width: 100%; max-width: 560px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 26px; padding: 22px 18px; animation: rise 0.25s ease; margin: auto 0; }
.modal-close { position: sticky; top: 0; float: right; z-index: 2; width: 34px; height: 34px; margin: -8px -6px 0 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.result-emoji { font-size: 56px; animation: pop 0.5s ease; }
.result h2 { font-size: 22px; font-weight: 900; }
.result .reaction { text-align: left; width: 100%; margin-top: 4px; }
.result-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }
.copy-box { width: 100%; text-align: left; white-space: pre-wrap; font-family: inherit; font-size: 14px; background: var(--surface-2); border-radius: 14px; padding: 14px; user-select: all; }
.preview-wrap { display: flex; flex-direction: column; gap: 10px; }
.reaction { display: flex; gap: 10px; align-items: flex-start; }
.reaction .bubble { background: var(--surface-2); padding: 10px 14px; border-radius: 16px; border-top-left-radius: 6px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.reaction .bubble b { font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 60; background: #2a2230; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; opacity: 0; transition: all 0.25s ease; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 피드백 리포트 (HTML 스타일) */
.report { background: var(--surface); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.report-head { padding: 24px 20px 20px; background: linear-gradient(135deg, #2a2230, #503858); color: #fff; display: flex; flex-direction: column; gap: 4px; }
.report-kicker { font-size: 11px; letter-spacing: 0.16em; font-weight: 800; color: #ffb3c1; }
.report-head h2 { font-size: 22px; line-height: 1.3; font-weight: 800; }
.report-head p { color: rgba(255, 255, 255, 0.82); font-size: 13.5px; }
.report-date { font-size: 12.5px !important; }
.report-log { margin-top: 10px; align-self: flex-start; font-size: 12.5px; background: rgba(255, 255, 255, 0.13); padding: 6px 12px; border-radius: 99px; }
.report-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.rb p { white-space: pre-wrap; }
.rb-text p { font-size: 15.5px; line-height: 1.7; }
.rb-good, .rb-fix, .rb-plan { padding: 14px 16px; border-radius: 16px; }
.rb-good { background: var(--good-bg); }
.rb-good .rb-label { color: var(--good); }
.rb-fix { background: var(--warn-bg); }
.rb-fix .rb-label { color: var(--warn); }
.rb-plan { background: var(--plan-bg); }
.rb-plan .rb-label { color: var(--plan); }
.rb-label { font-weight: 800; font-size: 13px; margin-bottom: 4px; }
.rb-media video, .rb-media img { width: 100%; border-radius: 16px; background: #000; display: block; max-height: 72vh; }
.rb-media img { background: none; }
.rb-media figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; padding: 0 2px; }
.yt { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #000; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.report-foot { padding: 16px 18px 20px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 12px; }
.report-sign { text-align: right; font-weight: 800; }

/* ---------- 트레이너 */
.dash-grid { display: grid; gap: 12px; }
@media (min-width: 760px) { .dash-grid { grid-template-columns: 320px 1fr; align-items: stretch; } .dash-grid .stats { align-content: stretch; } }
.code-card { border-radius: var(--radius); padding: 18px; background: linear-gradient(135deg, #2a2230, #503858); color: #fff; display: flex; flex-direction: column; gap: 4px; }
.code-card span { font-size: 13px; font-weight: 700; opacity: 0.85; }
.code-card .code { font-size: 46px; font-weight: 900; letter-spacing: 0.22em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.code-card p { font-size: 12.5px; opacity: 0.8; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.action-row .btn { flex: 1; }
.progress-list { display: flex; flex-direction: column; gap: 10px; }
.progress-row { display: flex; gap: 10px; align-items: center; }
.switch-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch-row input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; }
.switch-row .muted { font-size: 13px; }
details.card summary { font-weight: 800; cursor: pointer; }
.profile { gap: 2px; }
.profile b { font-size: 18px; }

.log-ref { gap: 4px; }
.log-ref .card-title { margin-bottom: 4px; }
.quote-media { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.quote-list { display: flex; flex-wrap: wrap; gap: 6px; }
.quote-btn { border: 1.5px dashed var(--line); background: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.blocks { display: flex; flex-direction: column; gap: 10px; }
.blocks-empty { text-align: center; color: var(--muted); font-size: 14px; padding: 22px 16px; border: 1.5px dashed var(--line); border-radius: var(--radius); }
.blk { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.blk-good { border-left-color: var(--good); }
.blk-fix { border-left-color: var(--warn); }
.blk-plan { border-left-color: var(--plan); }
.blk-video, .blk-image, .blk-youtube { border-left-color: var(--info); }
.blk-text { border-left-color: var(--primary); }
.blk-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.blk-tools { display: flex; gap: 4px; }
.blk-fields { display: flex; flex-direction: column; gap: 8px; }
.blk-fields video, .blk-fields img { width: 100%; border-radius: 12px; background: #000; max-height: 50vh; }
.upload-drop { border: 2px dashed var(--line); background: var(--bg); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.upload-icon { font-size: 28px; }
.upload-progress { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.blk-add { display: flex; flex-wrap: wrap; gap: 6px; }
.composer-actions { position: sticky; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 2fr; gap: 8px; padding: 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-radius: 18px; border: 1px solid var(--line); z-index: 5; }
.composer-actions .btn { min-height: 50px; }

@media (max-width: 420px) {
  .stats.four { grid-template-columns: repeat(2, 1fr); }
  .hello h1 { font-size: 21px; }
}

/* ---------- AI 트레이너 */
.portrait.coach { background: linear-gradient(135deg, #3b4a7d, #1f2747); }
.portrait .ai-badge { position: absolute; right: -0.35em; bottom: -0.2em; font-size: 0.32em; min-width: 2.2em; padding: 0.15em 0.35em; border-radius: 99px; background: #fff; color: #1f2747; font-weight: 900; text-shadow: none; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); line-height: 1.2; text-align: center; }
.coach-hero { border-radius: 26px; padding: 18px; color: #fff; background: linear-gradient(135deg, #3b4a7d, #1f2747); box-shadow: 0 14px 34px rgba(31, 39, 71, 0.3); display: flex; flex-direction: column; gap: 14px; }
.coach-hero .portrait { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4); }
.coach-last { background: rgba(255, 255, 255, 0.12); border-radius: 14px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.coach-last-who { font-size: 12px; font-weight: 800; opacity: 0.8; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.mode-pick { align-items: center; text-align: center; }
.mode-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.mode-card.on { border-color: var(--primary); }
.mode-head { display: flex; gap: 12px; align-items: flex-start; }
.mode-head > div { flex: 1; }
.mode-head b { font-size: 17px; }
.mode-emoji { font-size: 34px; line-height: 1; }
.mode-points { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.mode-now { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; }

.coach-stage { background: linear-gradient(135deg, #3b4a7d, #1f2747); }
.stage-sub { font-size: 12px; opacity: 0.8; }
.bubble-wrap { display: flex; flex-direction: column; gap: 3px; max-width: 80%; min-width: 0; }
.bubble-wrap .bubble { max-width: 100%; }
.bubble-who { font-size: 11.5px; font-weight: 800; color: var(--muted); padding-left: 4px; }
.trainer-msg .bubble { border: 1.5px solid var(--primary); background: var(--primary-soft); }
.trainer-msg .bubble-who { color: var(--primary); }
.coach-page .chat-empty p { max-width: 340px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.coach-input { flex: 1; resize: none; min-height: 46px; max-height: 120px; padding: 12px 14px; border-radius: 16px; line-height: 1.4; }
.send-btn { width: 46px; height: 46px; flex: none; border: 0; border-radius: 50%; background: linear-gradient(135deg, var(--primary-2), var(--primary)); color: #fff; font-size: 20px; font-weight: 900; cursor: pointer; }
.send-btn:disabled { opacity: 0.5; }
.quick-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.quick-chips .chip { white-space: nowrap; font-size: 13px; padding: 7px 12px; }
.consent-card { margin: auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 22px 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; box-shadow: var(--shadow); }
.consent-card h2 { font-size: 19px; font-weight: 900; }
.consent-card ul { text-align: left; margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--muted); }

.alert-card { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn-bg) 60%, var(--surface)); }
.alert-list { display: flex; flex-direction: column; }
.alert-row { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.alert-row:first-child { border-top: 0; }
.alert-text { flex: 1; min-width: 0; }

.coach-log { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; padding: 2px; }
.coach-row { border-radius: 14px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; }
.coach-row.member { background: var(--surface-2); }
.coach-row.trainer { border-color: var(--primary); }
.coach-row-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }

.status-card.ok { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.status-card.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); background: color-mix(in srgb, var(--warn-bg) 50%, var(--surface)); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.preview-out { display: flex; flex-direction: column; gap: 6px; }
.preview-out .msg .bubble { background: var(--bg); }

/* ---------- AI 이용권 */
.paywall { margin-top: 8px; background: var(--surface); border: 1.5px solid #3b4a7d; border-radius: 22px; padding: 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; box-shadow: var(--shadow); }
.paywall b { font-size: 18px; }
.paywall .price { font-size: 20px; font-weight: 900; color: #3b4a7d; }
.paywall ul { text-align: left; margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.pay-guide { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; font-size: 14px; text-align: left; width: 100%; }
@media (prefers-color-scheme: dark) { .paywall { border-color: #6b7cc0; } .paywall .price { color: #a9b6ff; } }
.pass-card.on { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.pass-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pass-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pass-history { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); padding-top: 6px; }
.request-card { border-color: color-mix(in srgb, var(--info) 40%, var(--line)); background: color-mix(in srgb, var(--info-bg) 60%, var(--surface)); }
.form-group { display: flex; flex-direction: column; gap: 12px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.cost-table { display: flex; flex-direction: column; }
.cost-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.cost-row:first-child { border-top: 0; }
.cost-name { display: flex; gap: 6px; align-items: center; min-width: 0; }

/* ---------- 앱 설치 안내 */
.install-banner { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--line)); }
.install-banner .notice-text span { color: var(--muted); }
.install-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.install-steps li::marker { font-weight: 800; color: var(--primary); }
.card.current { border-color: var(--primary); box-shadow: 0 10px 28px rgba(255, 94, 126, 0.15); }
.warn-card { background: var(--warn-bg); border-color: transparent; box-shadow: none; }
.warn-card .card-title { color: var(--warn); }
[hidden] { display: none !important; }
