:root {
  --bg: #FFF9F2;
  --card: #FFFFFF;
  --ink: #14243B;
  --muted: #56617A;
  --line: #E9E1D5;
  --pink: #F8C8DC;
  --pink-soft: #FDEDF4;
  --blue: #A9D3F8;
  --blue-soft: #EAF4FD;
  --star: #F5C451;
  --danger: #A23B4C;
  --radius: 18px;
  --tabs-h: 64px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:lang(ko) { font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif; }
:lang(ko) body { word-break: keep-all; overflow-wrap: anywhere; }
:lang(zh-Hans) { font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.top { padding: 14px 16px 4px; max-width: 520px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.acct { min-height: 38px; padding: 6px 14px; font-size: .85rem; }

/* 로그인 */
.social { gap: 10px; border-color: var(--line); background: #fff; color: #1f1f1f; }
.social.google, .social.plain { border-color: #DADCE0; }
.social.kakao { background: #FEE500; border-color: #FEE500; color: #191919; }
.social.facebook { background: #1877F2; border-color: #1877F2; color: #fff; }
.social.apple, .social.dark { background: #000; border-color: #000; color: #fff; }
.social.linkedin { background: #0A66C2; border-color: #0A66C2; color: #fff; }
.social.discord { background: #5865F2; border-color: #5865F2; color: #fff; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.brand { display: inline-flex; flex-direction: column; align-items: flex-start; }
.logo { height: 36px; width: auto; display: block; }
.tagline { font-size: 11px; letter-spacing: .08em; color: var(--muted); margin: -2px 0 0 4px; font-family: Georgia, "Times New Roman", serif; font-style: italic; }

main { max-width: 520px; margin: 0 auto; padding: 8px 16px 24px; outline: none; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.now { border: 2px solid var(--ink); box-shadow: 0 6px 0 var(--pink); }
.label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
:lang(ko) .label, :lang(zh-Hans) .label { letter-spacing: 0; }

.btn {
  appearance: none; border: 2px solid var(--ink); background: var(--card); border-radius: 999px;
  padding: 10px 16px; min-height: 44px; font-weight: 600; cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.soft { border-color: var(--line); background: var(--blue-soft); }
.btn.ghost { border-color: transparent; background: transparent; text-decoration: underline; padding: 8px 10px; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, .tab:focus-visible {
  outline: 3px solid #3D7BD9; outline-offset: 2px;
}
.chip { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; min-height: 40px; cursor: pointer; font-weight: 600; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--pink-soft); }

.field { display: block; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 12px 14px; min-height: 48px;
}
textarea.input { resize: vertical; min-height: 64px; }
.input:focus { border-color: var(--ink); }

/* 지금 카드 */
.now-head { display: flex; gap: 12px; align-items: flex-start; }
.now-head .txt { flex: 1; min-width: 0; }
.step-text { font-size: 1.25rem; font-weight: 700; margin: 4px 0 2px; overflow-wrap: anywhere; }
.task-of { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.buddy { width: 64px; height: 64px; flex: none; }
.buddy.lg { width: 96px; height: 96px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.badge { font-size: .7rem; border-radius: 999px; padding: 2px 8px; background: var(--blue-soft); color: var(--ink); white-space: nowrap; }
details > summary { cursor: pointer; font-weight: 600; padding: 8px 0; list-style-position: inside; }
.menu { display: grid; gap: 8px; margin-top: 10px; }

/* 집중: 1인 독서실 부스 */
.booth {
  position: relative; border-radius: 24px; overflow: hidden; background: #fff;
  border: 10px solid #EFE6D8; border-top-width: 0; box-shadow: inset 0 0 0 2px var(--line);
}
.booth-scene { height: 120px; background: url(assets/focus-room.svg) center 35% / cover no-repeat; opacity: .9; }
.booth-body { padding: 0 16px 18px; margin-top: -56px; position: relative; text-align: center; }
.booth .buddy { margin: 0 auto; display: block; }
.timer-wrap { position: relative; width: 220px; max-width: 70vw; margin: 8px auto 4px; aspect-ratio: 1; }
.timer-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-digits { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-digits .num { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.timer-digits .cap { font-size: .8rem; color: var(--muted); }
.ring-bg { stroke: var(--blue-soft); }
.ring-fg { stroke: var(--ink); transition: stroke-dashoffset .9s linear; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.focus-actions { display: grid; gap: 10px; margin-top: 14px; }
.focus-actions .row { justify-content: center; }

/* 하단 탭 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 249, 242, .96); border-top: 1px solid var(--line);
  display: flex; justify-content: center; z-index: 10;
}
.tab { flex: 1; max-width: 130px; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: .8rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"] .dot { background: var(--pink); }
.tab .dot { width: 36px; height: 4px; border-radius: 4px; background: transparent; }

/* 오버레이 */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 36, 59, .35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto; border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 1.2rem; }
.step-edit { display: flex; gap: 8px; align-items: center; }
.step-edit .input { flex: 1; }
.icon-btn { border: 2px solid var(--line); background: #fff; border-radius: 12px; min-width: 44px; min-height: 44px; cursor: pointer; font-size: 1.1rem; }
.note { background: var(--blue-soft); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.note.warn { background: var(--pink-soft); }
.reward { text-align: center; }
.reward .stars { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 1.6rem; font-weight: 800; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 16px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; }

/* 통계 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; }
.stat span { font-size: .75rem; color: var(--muted); }
.day h3 { font-size: .9rem; color: var(--muted); margin: 14px 0 4px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { width: 48px; height: 28px; accent-color: var(--ink); }

/* 움직임: 켠 경우에만 */
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@keyframes hop { 0% { transform: translateY(0); } 35% { transform: translateY(-10px); } 70% { transform: translateY(0); } 85% { transform: translateY(-3px); } 100% { transform: translateY(0); } }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
body.motion .buddy[data-state="idle"] { animation: breathe 5s ease-in-out infinite; }
body.motion .buddy[data-state="focus"] { animation: breathe 8s ease-in-out infinite; }
body.motion .buddy[data-state="done"] { animation: hop .9s ease-out 1; }
body.motion .sheet { animation: fadein .2s ease-out; }
body:not(.motion) *, body:not(.motion) *::before, body:not(.motion) *::after { animation: none !important; transition: none !important; }

/* 광고 자리: 광고 계정이 연결되기 전에는 hidden */
.ad-slot { max-width: 520px; margin: 8px auto; padding: 0 16px; min-height: 50px; text-align: center; overflow: hidden; }
body.landing .ad-slot { max-width: 720px; }
