/* ============================================
   마이루틴 디자인 토큰 + 공통 스타일 (v3 "종이 일기장" 테마)
   방향: 따뜻한 종이 질감 + 손그림 스케치 + 아기자기
   - 라이트: 크림색 종이 / 다크: 소프트 차콜(웜 그레이 + 크림 + 피치 포인트)
   - 수동 토글: html[data-theme=light|dark] (없으면 시스템 설정)
   - 스케치 요소: 비대칭 border-radius + 딱 떨어지는 오프셋 그림자
   ============================================ */
:root {
  color-scheme: light; /* 네이티브 컨트롤(시간 선택기·체크박스·스크롤바) 색 일치 — MDN color-scheme */
  --bg: #f6efe3;
  --surface: #fffdf6;
  --surface-2: #efe6d3;
  --text: #453a2b;
  --muted: #97896f;
  --line: #e2d6bd;
  --line-strong: #c9b995;
  --primary: #d96f4e;
  --primary-strong: #c25a39;
  --primary-soft: #fbe9df;
  --success: #6d9e58;
  --danger: #cf5140;
  --on-primary: #ffffff;   /* 프라이머리/성공 배경 위 글자·아이콘 색 (다크에서는 진한 잉크로 반전) */
  --invert-bg: #453a2b;
  --invert-text: #fdf8ec;
  --radius: 12px;
  --radius-lg: 16px;
  /* 스케치: 연필 오프셋 그림자 (부드러운 블러 대신 딱 떨어지는 그림자) */
  --shadow: 2px 3px 0 rgba(69, 58, 43, .07);
  --shadow-lg: 4px 5px 0 rgba(69, 58, 43, .1);
  /* 손그림 비대칭 라운드 (근거: 기획서 9장 hand-drawn border 기법) */
  --sketch-sm: 10px 13px 11px 14px / 13px 10px 14px 11px;
  --sketch-lg: 15px 19px 16px 20px / 19px 15px 20px 16px;
  --font-hand: "Gaegu", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191917;
  --surface: #232320;
  --surface-2: #2e2e2a;
  --text: #f0ece1;
  --muted: #a5a196;
  --line: #363631;
  --line-strong: #4f4f47;
  --primary: #f59c73;
  --primary-strong: #f8b48f;
  --primary-soft: #383028;
  --success: #a3cc8b;
  --danger: #ee8a76;
  --on-primary: #2c211a;
  --invert-bg: #f0ece1;
  --invert-text: #262622;
  --shadow: 2px 3px 0 rgba(0, 0, 0, .28);
  --shadow-lg: 4px 5px 0 rgba(0, 0, 0, .34);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191917;
    --surface: #232320;
    --surface-2: #2e2e2a;
    --text: #f0ece1;
    --muted: #a5a196;
    --line: #363631;
    --line-strong: #4f4f47;
    --primary: #f59c73;
    --primary-strong: #f8b48f;
    --primary-soft: #383028;
    --success: #a3cc8b;
    --danger: #ee8a76;
    --on-primary: #2c211a;
    --invert-bg: #f0ece1;
    --invert-text: #262622;
    --shadow: 2px 3px 0 rgba(0, 0, 0, .28);
    --shadow-lg: 4px 5px 0 rgba(0, 0, 0, .34);
  }
}
/* 다크에서는 종이 노이즈를 절반으로 (밝은 입자가 먼지처럼 떠 보이는 것 방지) */
:root[data-theme="dark"] body::before { opacity: .5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before { opacity: .5; }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
/* 종이 질감 — SVG 노이즈를 아주 옅게 전체에 깐다 (양 테마 공통) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
svg { display: block; }
::selection { background: var(--primary); color: var(--on-primary); }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: var(--radius); font-weight: 700; font-size: .95rem;
  transition: transform .12s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--text); background: var(--surface); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 1.02rem; }
.btn[disabled] { opacity: .55; cursor: default; pointer-events: none; }
.btn-block { width: 100%; }

/* ---------- 랜딩: 헤더 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.08rem; letter-spacing: -.01em; }
.brand .logo-mark {
  color: var(--on-primary); background: var(--primary); border-radius: 8px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions .btn { min-height: 38px; padding: 0 16px; font-size: .88rem; }
.header-actions .link { font-size: .9rem; font-weight: 600; color: var(--muted); padding: 8px 10px; }
.header-actions .link:hover { color: var(--text); }

/* ---------- 랜딩: 히어로 ---------- */
.hero { padding: 88px 0 72px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(560px 320px at 78% 18%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%);
}
.hero .container { position: relative; display: grid; grid-template-columns: 1fr; gap: 56px; align-items: center; }
@media (min-width: 880px) { .hero .container { grid-template-columns: 1.05fr .95fr; } }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .82rem; font-weight: 700; color: var(--primary);
  margin-bottom: 18px; letter-spacing: .01em;
}
.hero h1 {
  font-size: clamp(2.3rem, 6vw, 3.7rem);
  font-weight: 800; line-height: 1.14; letter-spacing: -.035em;
  word-break: keep-all;
}
.hero h1 .accent { color: var(--primary); }
.hero .sub {
  margin-top: 20px; font-size: 1.06rem; color: var(--muted); max-width: 27em;
  word-break: keep-all;
}
.hero-cta { margin-top: 32px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hero-cta .more {
  font-size: .95rem; font-weight: 700; color: var(--text);
  display: inline-flex; align-items: center; gap: 5px;
  border-bottom: 1.5px solid var(--line-strong); padding-bottom: 2px;
}
.hero-cta .more:hover { border-color: var(--text); }
.hero-note { margin-top: 16px; font-size: .84rem; color: var(--muted); }

/* ---------- 랜딩: 앱 미리보기 목업 ---------- */
.mock {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 20px; max-width: 350px; margin: 0 auto; width: 100%;
}
.mock-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.mock-head .day { font-size: .8rem; color: var(--muted); font-weight: 700; }
.mock-head .pct { font-size: .92rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.mock-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 14px; }
.mock-bar i { display: block; height: 100%; width: 62%; border-radius: 99px; background: var(--primary); }
.mock-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 8px;
  font-size: .9rem; font-weight: 600;
}
.mock-item:last-child { margin-bottom: 0; }
.mock-item .t { color: var(--muted); font-weight: 700; font-size: .78rem; min-width: 40px; font-variant-numeric: tabular-nums; }
.mock-item .c {
  margin-left: auto; width: 21px; height: 21px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mock-item.on { opacity: .55; }
.mock-item.on .txt { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.mock-item.on .c { background: var(--success); border-color: var(--success); color: var(--on-primary); }
.mock-item.now { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.mock-item.now .t { color: var(--primary); }

/* ---------- 랜딩: 섹션 공통 ---------- */
.section { padding: 76px 0; border-top: 1px solid var(--line); }
.section-eyebrow { font-size: .82rem; font-weight: 800; color: var(--primary); letter-spacing: .06em; margin-bottom: 10px; }
.section-title {
  font-size: clamp(1.6rem, 3.6vw, 2.3rem); font-weight: 800; letter-spacing: -.03em;
  line-height: 1.25; word-break: keep-all;
}
.section-sub { color: var(--muted); margin-top: 12px; max-width: 34em; word-break: keep-all; }

/* ---------- 랜딩: 기능 벤토 그리드 ---------- */
.bento { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 44px; }
@media (min-width: 760px) { .bento { grid-template-columns: repeat(3, 1fr); } .bento .wide { grid-column: span 2; } }
.bento-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.bento-card .icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.bento-card h3 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; }
.bento-card p { font-size: .9rem; color: var(--muted); word-break: keep-all; }
.bento-card .visual { margin-top: auto; padding-top: 18px; }

/* 벤토 내부 미니 비주얼: 주간 바 차트 */
.mini-week { display: flex; align-items: flex-end; gap: 8px; height: 74px; }
.mini-week i { flex: 1; border-radius: 6px 6px 3px 3px; background: color-mix(in srgb, var(--primary) 22%, var(--surface-2)); }
.mini-week i.hi { background: var(--primary); }
.mini-week-labels { display: flex; gap: 8px; margin-top: 8px; }
.mini-week-labels span { flex: 1; text-align: center; font-size: .7rem; color: var(--muted); font-weight: 700; }

/* 벤토 내부 미니 비주얼: 요일 칩 */
.day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chips span {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: var(--muted);
}
.day-chips span.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ---------- 랜딩: 사용 방법 (번호 리스트) ---------- */
.steps { margin-top: 44px; display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 36px; } }
.step { padding: 22px 0; border-top: 1px solid var(--line); }
@media (min-width: 760px) { .step { padding: 0; border-top: 2px solid var(--line-strong); padding-top: 20px; } }
.step .num { font-size: .85rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.step h3 { font-size: 1.05rem; font-weight: 800; margin: 8px 0 6px; letter-spacing: -.01em; }
.step p { font-size: .9rem; color: var(--muted); word-break: keep-all; }

/* ---------- 랜딩: 루틴 가이드 (AdSense 심사용 공개 콘텐츠 겸함) ---------- */
.guide-grid { display: grid; grid-template-columns: 1fr; gap: 28px 40px; margin-top: 44px; }
@media (min-width: 760px) { .guide-grid { grid-template-columns: 1fr 1fr; gap: 36px 48px; } }
.guide-item { border-top: 2px solid var(--line-strong); padding-top: 18px; }
.guide-item h3 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: 8px; word-break: keep-all; }
.guide-item p { font-size: .92rem; color: var(--muted); word-break: keep-all; }

/* ---------- 랜딩: FAQ ---------- */
.faq { max-width: 720px; margin-top: 36px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary {
  font-weight: 700; cursor: pointer; list-style: none; padding: 18px 4px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary .chev { transition: transform .2s; color: var(--muted); flex-shrink: 0; }
.faq details[open] summary .chev { transform: rotate(180deg); }
.faq .a { padding: 0 4px 18px; font-size: .92rem; color: var(--muted); max-width: 40em; word-break: keep-all; }

/* ---------- 랜딩: 마지막 CTA + 푸터 ---------- */
.cta-final {
  background: var(--invert-bg); color: var(--invert-text);
  border-radius: var(--radius-lg); padding: 56px 24px; text-align: center;
}
.cta-final h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 800; letter-spacing: -.03em; word-break: keep-all; }
.cta-final p { opacity: .65; margin: 12px 0 28px; }
.cta-final .btn-primary { background: var(--primary); }
.site-footer { border-top: 1px solid var(--line); padding: 36px 0 48px; margin-top: 76px; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; font-size: .82rem; color: var(--muted); }
.site-footer nav { display: flex; gap: 18px; }
.site-footer a:hover { color: var(--text); }

/* ---------- 앱 유사 터치 동작 (body.app-like — 인증/앱 화면 전용) ----------
   랜딩은 공개 웹 문서라 확대·선택을 막지 않는다 (접근성/AdSense).
   앱 화면은 네이티브처럼: 당겨서 새로고침·바운스·더블탭 확대·UI 텍스트 선택 차단. */
body.app-like {
  overscroll-behavior-y: none;             /* 당겨서 새로고침 + 스크롤 바운스 전파 차단 */
  -webkit-user-select: none; user-select: none;   /* 버튼/라벨 등 UI 선택 방지 */
  -webkit-touch-callout: none;             /* iOS 길게 눌러 콜아웃 메뉴 방지 */
}
body.app-like, body.app-like * { touch-action: manipulation; }  /* 더블탭 확대 제거 (스크롤·핀치는 유지, 핀치는 뷰포트 메타로 잠금) */
body.app-like input, body.app-like textarea {
  -webkit-user-select: text; user-select: text;   /* 입력값은 선택/복사 가능해야 함 */
}

/* 노치/홈 인디케이터 안전 영역 */
@supports (padding: max(0px)) {
  .site-header .container { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .auth-main { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); padding-bottom: max(64px, env(safe-area-inset-bottom)); }
  .center-page { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}

/* ---------- 인증 화면 (로그인/가입/재설정) ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 20px 64px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.auth-card .desc { color: var(--muted); font-size: .93rem; margin-bottom: 28px; word-break: keep-all; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .86rem; font-weight: 700; }
.field .hint { font-size: .8rem; color: var(--muted); }
.input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
  font-size: 16px; /* 16px 미만이면 iOS Safari가 포커스 시 자동 확대 — 절대 줄이지 말 것 */
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.input.code { text-align: center; font-size: 1.5rem; font-weight: 800; letter-spacing: .5em; padding-left: calc(14px + .5em); font-variant-numeric: tabular-nums; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); border-radius: 8px;
}
.pw-toggle:hover { color: var(--text); }
/* 필드별 실시간 검증 메시지 (가입 폼) */
.field-err { display: none; font-size: .8rem; color: var(--danger); word-break: keep-all; }
.field-err.show { display: block; }
.input.invalid { border-color: var(--danger); }
.input.invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
.check-row a { font-weight: 700; color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }

.form-msg { display: none; font-size: .88rem; border-radius: var(--radius); padding: 12px 14px; word-break: keep-all; }
.form-msg.show { display: block; }
.form-msg.error { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger); }
.form-msg.ok { background: color-mix(in srgb, var(--success) 10%, var(--surface)); color: var(--success); }
.auth-links { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); text-align: center; }
.auth-links a { font-weight: 700; color: var(--primary); display: inline-block; padding: 6px 8px; } /* 터치 여유 + 전체폭 오터치 방지 */
.auth-links a:hover { text-decoration: underline; }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-size: .9rem; font-weight: 600; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; margin-top: 3px; } /* 두 줄 라벨에서도 첫 줄과 정렬 */
.resend-row { display: flex; align-items: center; justify-content: space-between; font-size: .86rem; color: var(--muted); }
.resend-row button { font-weight: 700; color: var(--primary); }
.resend-row button[disabled] { color: var(--muted); cursor: default; }

/* ============================================
   앱 셸 (M3) — 모바일 하단 탭바 / PC 사이드바
   ============================================ */
.app-layout { min-height: 100vh; min-height: 100dvh; }
.app-side { display: none; }

.app-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px; padding-top: max(14px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.app-top h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.top-settings {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); border-radius: 10px;
}
.top-settings:active { background: var(--surface-2); }

.app-main {
  padding: 4px 20px calc(84px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; width: 100%;
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 7px; font-size: .7rem; font-weight: 700; color: var(--muted); min-height: 50px;
}
.tabbar a.active { color: var(--primary); }

@media (min-width: 768px) {
  .app-layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
  .app-side {
    display: flex; flex-direction: column; gap: 6px;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    border-right: 1px solid var(--line); padding: 20px 14px;
  }
  .app-side .brand { padding: 4px 10px 18px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a, .side-settings {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 12px; border-radius: var(--radius);
    font-weight: 700; font-size: .93rem; color: var(--muted);
    transition: background .12s, color .12s;
  }
  .side-nav a:hover, .side-settings:hover { background: var(--surface-2); color: var(--text); }
  .side-nav a.active, .side-settings.active { background: var(--primary-soft); color: var(--primary); }
  .side-settings { margin-top: auto; }
  .tabbar { display: none; }
  .app-top { position: static; background: none; backdrop-filter: none; padding: 26px 32px 12px; }
  .app-top h1 { font-size: 1.55rem; }
  .top-settings { display: none; }
  .app-main { padding: 8px 32px 64px; margin: 0; max-width: 680px; }
}

/* ---------- 상태 화면 (로딩 스켈레톤 / 빈 상태 / 에러) ---------- */
.state { text-align: center; padding: 56px 20px; color: var(--muted); }
.state .icon { display: flex; justify-content: center; margin-bottom: 14px; color: var(--muted); }
.state h2 { font-size: 1.05rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.state p { font-size: .9rem; margin-bottom: 20px; word-break: keep-all; }
.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 55%, var(--bg)) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%) translateY(8px);
  background: var(--invert-bg); color: var(--invert-text);
  font-size: .88rem; font-weight: 600; padding: 11px 18px; border-radius: 99px;
  opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 768px) { .toast { bottom: 32px; } }

/* ---------- 오늘 화면 ---------- */
.today-date { font-size: .86rem; font-weight: 700; color: var(--muted); margin: 6px 0 14px; }
.progress-card {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 22px; background: var(--surface); box-shadow: var(--shadow);
}
.progress-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.progress-head .label { font-size: .85rem; font-weight: 700; color: var(--muted); }
.progress-head .count { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.progress-head .count b { color: var(--primary); font-size: 1.25rem; }
.progress-track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: var(--primary); transition: width .45s cubic-bezier(.22, 1, .36, 1); }

.tpl-group { margin-bottom: 26px; }
.tpl-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tpl-group-head .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tpl-group-head h2 { font-size: .95rem; font-weight: 800; letter-spacing: -.01em; }

.check-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; min-height: 56px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  transition: border-color .15s, background .15s, opacity .2s;
}
.check-item .time { font-size: .78rem; font-weight: 700; color: var(--muted); min-width: 44px; font-variant-numeric: tabular-nums; }
.check-item .body { flex: 1; min-width: 0; }
.check-item .title { display: block; font-size: .95rem; font-weight: 600; }
.check-item .memo { display: block; font-size: .8rem; color: var(--muted); margin-top: 1px; }
.check-item .box {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  border: 1.75px solid var(--line-strong); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, transform .15s;
}
.check-item .box svg { opacity: 0; transform: scale(.4); transition: opacity .15s, transform .2s cubic-bezier(.34, 1.56, .64, 1); }
.check-item:active .box { transform: scale(.85); }
.check-item.checked { opacity: .62; }
.check-item.checked .title { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.check-item.checked .box { background: var(--success); border-color: var(--success); }
.check-item.checked .box svg { opacity: 1; transform: scale(1); }
.check-item.now { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.check-item.now .time { color: var(--primary); }

.celebrate {
  display: flex; align-items: center; gap: 16px; margin-bottom: 22px; padding: 22px;
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--line));
  background: color-mix(in srgb, var(--success) 7%, var(--surface));
  border-radius: var(--radius-lg);
  animation: pop-in .35s cubic-bezier(.34, 1.56, .64, 1);
}
.celebrate .art { color: var(--success); flex-shrink: 0; }
.celebrate h2 { font-size: 1.05rem; font-weight: 800; }
.celebrate p { font-size: .88rem; color: var(--muted); word-break: keep-all; }
@keyframes pop-in { from { transform: scale(.92); opacity: 0; } }

/* ---------- 템플릿 목록 ---------- */
.tpl-toolbar { margin: 4px 0 14px; }
.tpl-card {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 9px;
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-lg);
  padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow); transition: border-color .15s;
}
.tpl-card:hover { border-color: var(--line-strong); }
.tpl-card-head { display: flex; align-items: center; gap: 9px; }
.tpl-card-head .dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.tpl-card-head h2 { font-size: 1rem; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-badge { font-size: .7rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line-strong); padding: 2px 8px; border-radius: 99px; flex-shrink: 0; }
.tpl-card .meta { font-size: .82rem; color: var(--muted); }
.tpl-days { display: flex; gap: 4px; }
.tpl-days span {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line);
  font-size: .7rem; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.tpl-days span.on { background: var(--primary-soft); border-color: transparent; color: var(--primary); }

/* ---------- 템플릿 편집 ---------- */
.editor-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.editor-bar .back-btn {
  width: 40px; height: 40px; margin-left: -8px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.editor-bar .back-btn:active { background: var(--surface-2); }
.editor-bar h2 { font-size: 1.1rem; font-weight: 800; flex: 1; }
.editor-form { display: flex; flex-direction: column; gap: 20px; }

.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch { width: 34px; height: 34px; border-radius: 50%; padding: 0; border: 0; }
.color-swatch.on { outline: 2.5px solid var(--text); outline-offset: 2.5px; }

.day-select { display: flex; gap: 6px; }
.day-select button {
  flex: 1; height: 44px; border-radius: 9px; border: 1px solid var(--line-strong);
  font-size: .84rem; font-weight: 700; color: var(--muted); background: var(--surface);
  transition: background .12s, color .12s, border-color .12s;
}
.day-select button.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.item-editor { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 10px; display: grid; grid-template-columns: 26px 118px minmax(0, 1fr) 38px;
  gap: 7px; align-items: center;
}
.item-row.dragging { border-color: var(--primary); box-shadow: var(--shadow-lg); position: relative; z-index: 5; }
.item-row .grip {
  width: 26px; height: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: grab;
  touch-action: none; /* 드래그 중 스크롤 개입 차단 (Pointer Events 드래그 필수) */
}
.item-row.timed .grip { opacity: .22; cursor: default; touch-action: auto; }
.item-row .in-time { padding: 0 6px; min-height: 44px; font-variant-numeric: tabular-nums; }
/* 터치 기기: 필드 탭만으로 네이티브 피커가 열리므로 시계 아이콘을 숨겨 값 표시 공간 확보 (390px 실측 시 마지막 숫자 잘림) */
@media (pointer: coarse) {
  .item-row .in-time::-webkit-calendar-picker-indicator { display: none; }
}
/* PC: 아이콘 유지 대신 열을 넓게 */
@media (min-width: 768px) {
  .item-row { grid-template-columns: 26px 136px minmax(0, 1fr) 38px; }
}
.item-row .in-title { min-height: 44px; }
.item-row .del { width: 38px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 8px; }
.item-row .del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.item-row .in-memo { grid-column: 2 / -1; min-height: 42px; }

.add-item-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; width: 100%;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  font-weight: 700; font-size: .9rem; color: var(--muted);
  transition: color .12s, border-color .12s;
}
.add-item-btn:hover { color: var(--primary); border-color: var(--primary); }

.editor-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.btn-danger-ghost { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); background: var(--surface); }

/* ---------- 통계 화면 ---------- */
.stat-section {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.stat-title { font-size: .9rem; font-weight: 800; letter-spacing: -.01em; margin-bottom: 14px; }

.streak-card {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
  padding: 18px; margin: 6px 0 14px;
}
.streak-card .streak-icon {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted);
}
.streak-card.lit .streak-icon { background: var(--primary-soft); color: var(--primary); }
.streak-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.streak-num span { font-size: .95rem; font-weight: 800; margin-left: 4px; }
.streak-sub { font-size: .82rem; color: var(--muted); word-break: keep-all; }

/* 최근 7일 바 차트 — 단일 계열(프라이머리), 오늘만 강조 + 수치 직접 표기 */
.week-chart { display: flex; align-items: flex-end; gap: 10px; }
.wc-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.wc-track {
  width: 100%; max-width: 34px; height: 96px; border-radius: 8px;
  background: var(--surface-2); overflow: hidden;
  display: flex; align-items: flex-end;
}
.wc-track i {
  display: block; width: 100%; border-radius: 4px 4px 0 0;
  background: color-mix(in srgb, var(--primary) 55%, var(--surface-2));
  transition: height .5s cubic-bezier(.22, 1, .36, 1);
}
.wc-col.today .wc-track i { background: var(--primary); }
.wc-pct { font-size: .72rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.wc-pct.dim { color: var(--muted); font-weight: 700; }
.wc-day { font-size: .72rem; font-weight: 700; color: var(--muted); }
.wc-col.today .wc-day { color: var(--primary); }

/* 월간 히트맵 — 단일 색조 농도 램프 (l0 무기록 → l4 100%) */
.hm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.hm-head .stat-title { margin-bottom: 0; }
.hm-nav { display: flex; align-items: center; gap: 2px; }
.hm-nav button {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.hm-nav button:not([disabled]):active { background: var(--surface-2); }
.hm-nav button[disabled] { opacity: .3; cursor: default; }
.hm-title { font-size: .88rem; font-weight: 800; min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; }

.hm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
@media (min-width: 768px) {
  /* PC에서 셀이 과대해지지 않게 폭 제한 (실측: 680px 컨테이너에서 셀 86px) */
  .hm-grid { grid-template-columns: repeat(7, 54px); gap: 6px; justify-content: center; }
}
.hm-dow { text-align: center; font-size: .7rem; font-weight: 700; color: var(--muted); padding-bottom: 2px; }
.hm-cell {
  aspect-ratio: 1; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted);
}
.hm-cell.l1 { background: color-mix(in srgb, var(--primary) 22%, var(--surface-2)); color: var(--text); }
.hm-cell.l2 { background: color-mix(in srgb, var(--primary) 45%, var(--surface-2)); color: var(--on-primary); }
.hm-cell.l3 { background: color-mix(in srgb, var(--primary) 72%, var(--surface-2)); color: var(--on-primary); }
.hm-cell.l4 { background: var(--primary); color: var(--on-primary); }
.hm-cell.today { outline: 2px solid var(--primary); outline-offset: 1.5px; }
.hm-cell.future { background: transparent; border: 1px dashed var(--line); color: var(--line-strong); }

.hm-legend {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 12px; font-size: .7rem; font-weight: 700; color: var(--muted);
}
.hm-legend span { margin: 0 4px; }
.hm-legend i { width: 13px; height: 13px; border-radius: 4px; background: var(--surface-2); }
.hm-legend i.l1 { background: color-mix(in srgb, var(--primary) 22%, var(--surface-2)); }
.hm-legend i.l2 { background: color-mix(in srgb, var(--primary) 45%, var(--surface-2)); }
.hm-legend i.l3 { background: color-mix(in srgb, var(--primary) 72%, var(--surface-2)); }
.hm-legend i.l4 { background: var(--primary); }

/* ---------- 통계: 요약 타일 + 항목별 달성률 ---------- */
.sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.sum-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px 10px; text-align: center; min-width: 0;
}
.sum-num { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; }
.sum-num span { font-size: .82rem; font-weight: 800; margin-left: 2px; }
.sum-label { margin-top: 3px; font-size: .72rem; font-weight: 700; color: var(--muted); word-break: keep-all; }

.stat-title-sub { font-size: .74rem; font-weight: 700; color: var(--muted); margin-left: 6px; }
.item-stat { padding: 11px 0; border-top: 1px solid var(--line); }
.item-stat:first-of-type { border-top: 0; padding-top: 2px; }
.is-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; min-width: 0; }
.is-title { font-size: .9rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-time { font-style: normal; font-size: .76rem; font-weight: 700; color: var(--muted); margin-left: 7px; font-variant-numeric: tabular-nums; }
.is-val { flex-shrink: 0; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.is-val b { font-weight: 800; color: var(--text); }
.is-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.is-track i { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .3s cubic-bezier(.22, 1, .36, 1); }

/* ---------- 오프라인 배지 ---------- */
.offline-badge {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%) translateY(-110%);
  z-index: 70; margin-top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 7px;
  background: var(--invert-bg); color: var(--invert-text);
  font-size: .8rem; font-weight: 700; padding: 8px 14px; border-radius: 99px;
  transition: transform .3s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
.offline-badge.show { transform: translateX(-50%) translateY(0); }
.offline-badge svg { flex-shrink: 0; }

/* ---------- 설정 화면 ---------- */
.settings-list { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); margin-bottom: 18px; }
.settings-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--line); font-size: .93rem; }
.settings-item:last-child { border-bottom: 0; }
.settings-item .k { font-weight: 700; }
.settings-item .v { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.settings-link { min-height: 52px; }
.settings-link .chev, .settings-toggle .chev { color: var(--muted); display: flex; }
.settings-link:active { background: var(--surface-2); }

/* 접이식 섹션 (비밀번호 변경 / 회원 탈퇴) */
.settings-section {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden; margin-bottom: 18px;
}
.settings-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 15px 16px; min-height: 52px; font-size: .93rem; text-align: left;
}
.settings-toggle .k { font-weight: 700; }
.settings-section.open .settings-toggle .chev { transform: rotate(90deg); }
.settings-toggle .chev { transition: transform .18s ease; }
.settings-form {
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 16px 18px; border-top: 1px solid var(--line); padding-top: 16px;
}
.settings-section.danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.settings-section.danger .settings-toggle .k { color: var(--danger); }
.danger-note {
  font-size: .88rem; color: var(--danger); word-break: keep-all;
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border-radius: var(--radius); padding: 12px 14px;
}
.danger-note b { font-weight: 800; }
.btn-danger { background: var(--danger); color: var(--on-primary); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.settings-list + .btn-block, .btn-block + .settings-section { margin-top: 0; }
#logout-btn { margin-bottom: 18px; }

/* ---------- 광고 슬롯 (AdSense 승인 후 코드 삽입 — 비어 있으면 숨김) ---------- */
.ad-slot { margin: 28px 0; text-align: center; overflow: hidden; }
.ad-slot:empty { display: none; margin: 0; }

/* ---------- 정책 문서 페이지 (/privacy, /terms) ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 48px 20px 72px; }
.legal h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); font-weight: 800; letter-spacing: -.03em; word-break: keep-all; }
.legal .legal-date { color: var(--muted); font-size: .88rem; margin: 10px 0 36px; }
.legal h2 { font-size: 1.12rem; font-weight: 800; letter-spacing: -.01em; margin: 36px 0 10px; word-break: keep-all; }
.legal p, .legal li { font-size: .93rem; color: var(--text); word-break: keep-all; }
.legal p { margin-bottom: 10px; }
.legal ul, .legal ol { padding-left: 22px; margin-bottom: 10px; }
.legal li { margin-bottom: 5px; }
.legal a { color: var(--primary); font-weight: 600; }
.legal a:hover { text-decoration: underline; }
.legal .note { color: var(--muted); font-size: .86rem; }
.legal table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .88rem; }
.legal th, .legal td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; word-break: keep-all; }
.legal th { background: var(--surface-2); font-weight: 700; }

/* ---------- 유틸 화면 (준비중/404) ---------- */
.center-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px; }
.center-page .icon { color: var(--muted); margin-bottom: 10px; }
.center-page h1 { font-size: 1.4rem; font-weight: 800; }
.center-page p { color: var(--muted); font-size: .95rem; margin-bottom: 18px; }

/* ============================================
   v3 "종이 일기장" 스케치 레이어
   — 토큰 교체만으로 색은 이미 바뀌었고, 여기서 형태(라운드·그림자·손글씨)를 덧입힌다
   ============================================ */

/* 손글씨 폰트: 제목·라벨·버튼 등 포인트에만 (본문은 시스템 폰트 유지 — 가독성) */
.brand,
.hero h1, .hero-eyebrow, .section-title, .section-eyebrow,
.auth-card h1, .app-top h1,
.bento-card h3, .step h3, .step .num, .guide-item h3, .cta-final h2,
.stat-title, .hm-title, .streak-num, .sum-num,
.tabbar a span, .side-nav a span, .side-settings span,
.btn, .seg-btn, .de-badge, .de-head h2, .diary-card header h3, .ex-day-title,
.ex-intro h2, .ex-wait h2, .ex-partner-info h2,
.tpl-group-head h2, .tpl-card-head h2, .celebrate h2, .center-page h1 {
  font-family: var(--font-hand);
  letter-spacing: 0;
}
/* 일기 쓰기 영역은 본문도 손글씨 — 일기장 감성 (UI 안내문·설정 값 등은 시스템 폰트 유지) */
.diary-input, .dc-body, .mood-btn span, .ex-partner-status, .ex-day-title,
.field label, .settings-item .k, .settings-toggle .k {
  font-family: var(--font-hand);
}
.diary-input { font-size: 1.06rem; } /* Gaegu는 작게 보임 — iOS 자동확대 방지 위해 16px 이상 유지 */
.dc-body { font-size: 1.05rem; line-height: 1.8; }
.mood-btn span { font-size: .95rem; }
.field label { font-size: 1.02rem; }
.settings-item .k, .settings-toggle .k { font-size: 1.05rem; }

/* Gaegu는 같은 px에서 작게 보여 포인트 요소는 약간 키운다 */
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.2rem); line-height: 1.08; }
.section-title { font-size: clamp(1.9rem, 4.2vw, 2.7rem); }
.auth-card h1 { font-size: 1.95rem; }
.app-top h1 { font-size: 1.6rem; }
@media (min-width: 768px) { .app-top h1 { font-size: 1.8rem; } }
.btn { font-size: 1.08rem; }
.btn-lg { font-size: 1.2rem; }
.tabbar a { font-size: .84rem; }

/* 스케치 카드 — 비대칭 라운드 + 오프셋 그림자 */
.mock, .bento-card, .progress-card, .tpl-card, .stat-section, .streak-card,
.sum-card, .settings-list, .settings-section, .celebrate, .cta-final, .paper-card {
  border-radius: var(--sketch-lg);
}
.mock, .bento-card, .progress-card, .tpl-card, .stat-section, .streak-card, .sum-card, .paper-card {
  box-shadow: var(--shadow);
}
.check-item, .item-row, .mock-item { border-radius: var(--sketch-sm); }
.paper-card { background: var(--surface); border: 1px solid var(--line); padding: 18px; margin-bottom: 14px; }

/* 스케치 버튼 */
.btn { border-radius: var(--sketch-sm); }
.btn-primary { box-shadow: 2.5px 3px 0 color-mix(in srgb, var(--primary-strong) 45%, transparent); }
.btn-primary:active { box-shadow: 1px 1.5px 0 color-mix(in srgb, var(--primary-strong) 45%, transparent); }
.btn-ghost { box-shadow: var(--shadow); }
.input { border-radius: var(--sketch-sm); }
.logo-mark { border-radius: 8px 10px 8px 11px / 10px 8px 11px 8px; }

/* ---------- 세그먼트 컨트롤 (일기 탭 / 테마 선택) ---------- */
.seg {
  display: flex; gap: 6px; padding: 5px;
  background: var(--surface-2); border-radius: var(--sketch-sm);
  margin: 4px 0 16px;
}
.seg-btn {
  flex: 1; min-height: 42px; border-radius: var(--sketch-sm);
  font-weight: 700; font-size: 1.02rem; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg-btn.active {
  background: var(--surface); color: var(--primary);
  box-shadow: var(--shadow); border: 1px solid var(--line);
}

/* ---------- 일기 에디터 ---------- */
.diary-editor { display: flex; flex-direction: column; gap: 12px; }
.de-head { display: flex; align-items: center; gap: 8px; }
.de-head h2 { font-size: 1.3rem; font-weight: 700; flex: 1; }
.de-badge {
  font-size: .88rem; font-weight: 700; color: var(--primary);
  border: 1.5px dashed var(--primary);
  border-radius: 8px 10px 9px 11px / 10px 8px 11px 9px;
  padding: 1px 10px; flex-shrink: 0;
}
h3 .de-badge { font-size: .8rem; padding: 0 8px; margin-left: 4px; }

.mood-row { display: flex; gap: 6px; }
.mood-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 7px; border-radius: var(--sketch-sm);
  border: 1px solid var(--line); color: var(--muted); background: var(--surface);
  font-size: .74rem; font-weight: 700;
  transition: background .15s, color .15s, border-color .15s, transform .12s;
}
.mood-btn:active { transform: scale(.94); }
.mood-btn.on {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary);
}

/* 줄노트 질감 텍스트에어리어 — 줄 간격 = line-height(2em),
   background-position을 padding-top과 맞춰 글자가 줄 "위에" 앉게 한다 */
.diary-input {
  min-height: 150px; padding: 10px 14px; resize: vertical;
  line-height: 2em;
  background-image: repeating-linear-gradient(
    transparent, transparent calc(2em - 1px),
    var(--line) calc(2em - 1px), var(--line) 2em);
  background-position: 0 10px;   /* padding-top 만큼 내려 첫 줄부터 정렬 */
  background-attachment: local;  /* 스크롤 시 줄도 글자와 함께 이동 */
}

/* ---------- 일기 목록 ---------- */
.diary-list { margin-top: 22px; }
.diary-list .stat-title { font-size: 1.15rem; }
.diary-card { padding: 14px 16px; }
.diary-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.diary-card header h3 { font-size: 1.05rem; font-weight: 700; flex: 1; min-width: 0; }
.dc-mood { color: var(--primary); display: flex; flex-shrink: 0; }
.dc-del {
  width: 36px; height: 36px; margin-right: -8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); border-radius: 9px; flex-shrink: 0;
}
.dc-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.dc-body { font-size: .93rem; white-space: pre-wrap; word-break: break-word; }

/* ---------- 교환일기 ---------- */
.ex-intro, .ex-wait { display: flex; flex-direction: column; gap: 12px; padding: 24px 20px; }
.ex-wait { text-align: center; align-items: center; }
.ex-art { display: flex; justify-content: center; color: var(--primary); margin-bottom: 2px; }
.ex-art.pulse { animation: ex-pulse 1.8s ease-in-out infinite; }
@keyframes ex-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.07); opacity: .75; } }
.ex-intro h2, .ex-wait h2 { font-size: 1.45rem; font-weight: 700; }
.ex-intro > p, .ex-wait > p { font-size: .93rem; color: var(--muted); word-break: keep-all; }
.ex-rules { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ex-rules li {
  font-size: .88rem; color: var(--text); word-break: keep-all;
  padding: 10px 12px 10px 34px; position: relative;
  background: var(--surface-2); border-radius: var(--sketch-sm);
}
.ex-rules li::before {
  content: ""; position: absolute; left: 12px; top: 17px;
  width: 12px; height: 7px;
  border-left: 2px solid var(--primary); border-bottom: 2px solid var(--primary);
  transform: rotate(-48deg); border-radius: 1px;
}
.ex-partner { display: flex; align-items: center; gap: 13px; padding: 15px 16px; }
.ex-partner-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 14px 17px 15px 18px / 17px 14px 18px 15px;
}
.ex-partner-info h2 { font-size: 1.2rem; font-weight: 700; }
.ex-partner-info h2 b { color: var(--primary); }
.ex-partner-info p { font-size: .82rem; color: var(--muted); }
.ex-partner-status { font-size: .85rem; color: var(--muted); text-align: center; word-break: keep-all; }
.ex-day { margin-bottom: 18px; }
.ex-day-title { font-size: 1.02rem; font-weight: 700; color: var(--muted); margin: 14px 0 8px; }
.diary-card.mine { border-color: color-mix(in srgb, var(--primary) 38%, var(--line)); margin-left: 26px; }
.diary-card.mine header h3 { color: var(--primary); }
.diary-card.theirs { margin-right: 26px; }
#ex-leave { margin-top: 8px; }

/* ---------- 헤더 테마 탭 (해/달 — 전 화면) ---------- */
.theme-tab {
  display: flex; gap: 3px; padding: 3px; flex-shrink: 0;
  background: var(--surface-2); border-radius: 99px;
}
.theme-tab button {
  width: 36px; height: 30px; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 99px; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.theme-tab button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.app-top { gap: 10px; }
.app-top h1 { flex: 1; min-width: 0; }

/* ---------- 테마 선택 (설정) ---------- */
.theme-seg { margin: 0; background: var(--surface-2); }
.settings-form .theme-seg { margin-top: 4px; }
.settings-toggle .v { margin-left: auto; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
