/* 기본 스타일: 모바일 우선, RTL 대응을 위해 inline/block 논리 속성만 사용 */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 컴포넌트의 display 지정보다 숨김이 항상 우선 */
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* 바랜 종이 결: 아주 옅은 얼룩 + 잔 무늬 */
  background-image:
    radial-gradient(ellipse at 15% 0%, rgb(255 250 235 / 55%), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgb(200 160 110 / 10%), transparent 60%),
    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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .35 0 0 0 0 .2 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
  color: var(--text);
  font: 400 var(--fs-body)/1.6 var(--font);
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  padding-block-end: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--brand-text); }
h1, h2, h3 { letter-spacing: -0.02em; font-family: var(--font-title); }
/* 화면 제목(맨 위)만 로고와 같은 손글씨 */
:root:lang(ko) .page-head h1, :root:lang(en) .page-head h1 { font-family: var(--font-hand); font-weight: 400; letter-spacing: 0; }
h1 { font-size: var(--fs-title); font-weight: 700; line-height: 1.35; margin: 0 0 var(--sp-2); }
h2 { font-size: var(--fs-h2); font-weight: 700; line-height: 1.4; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }

/* 상단 바 */
.topbar {
  position: sticky; inset-block-start: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  height: var(--topbar-h); padding-inline: var(--space);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-block-end: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--text); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: block; box-shadow: 0 1px 2px rgb(80 60 40 / 18%); }
.brand-name { font-family: var(--font-hand); font-size: 1.1rem; line-height: 1; letter-spacing: 0; padding-block-start: 2px; }

/* 언어 선택 (JS 없이 동작) */
.top-icon { margin-inline-start: auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--text); }
.top-icon:hover { background: var(--surface-2); }
.top-icon .icon { width: 22px; height: 22px; }
.top-icon + .top-icon { margin-inline-start: 0; }
.top-icon.bell { position: relative; }
.dot-count { position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 0.6875rem; font-weight: 800; line-height: 18px; text-align: center; }
.lang-menu { position: relative; }
.lang-menu summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); font-size: var(--fs-sm); color: var(--text-sub); font-weight: 600;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul {
  position: absolute; inset-inline-end: 0; margin: var(--sp-2) 0 0; padding: var(--sp-2) 0;
  list-style: none; min-width: 200px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.lang-menu a { display: block; padding: 8px var(--sp-4); color: var(--text); text-decoration: none; }
.lang-menu a:hover { background: var(--surface-2); }
.lang-menu a[aria-current] { color: var(--brand-text); font-weight: 700; }

/* 본문 */
.page { max-width: 960px; margin: 0 auto; padding: var(--sp-4) var(--space) var(--sp-8); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.card.narrow { max-width: 420px; margin: 0 auto; }
.card.empty { text-align: center; padding-block: 48px; }
.sub { color: var(--text-sub); margin: 0 0 var(--sp-4); }

/* 버튼: 주황 버튼 글씨는 진갈색 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 var(--sp-5); border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 700; text-decoration: none; cursor: pointer; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn-block { width: 100%; }
.btn-icon { min-height: 40px; width: 40px; padding: 0; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn-danger { color: var(--danger); }

/* 폼 */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: var(--fs-sm); color: var(--text-sub); font-weight: 600; }
.form input, .form select, .form textarea {
  min-height: 48px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
}
.form textarea { padding: 12px 14px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.form .help { font-weight: 400; color: var(--text-sub); font-size: var(--fs-xs); }
.alert {
  margin: 0 0 var(--sp-3); padding: 10px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); font-size: var(--fs-sm);
}
.alert.ok { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); color: var(--ok); }

/* 하단 탭 5개: 아이콘 + 글자, 선택 탭은 위쪽 막대 */
.tabbar {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-block-end: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-block-start: 1px solid var(--line);
}
.tabbar a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-sub); text-decoration: none; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0;
}
.tabbar .icon { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--brand-text); font-weight: 700; }
.tabbar a[aria-current="page"]::before {
  content: ""; position: absolute; inset-block-start: 0; inset-inline: 30%;
  height: 3px; border-radius: 0 0 3px 3px; background: var(--brand);
}

/* 공통 부품 */
.icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-block-end: var(--sp-3); }
.toolbar .grow { flex: 1 1 auto; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 0 14px;
  border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.chip[aria-pressed="true"], .chip.is-on { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .icon { width: 16px; height: 16px; }
.chips-scroll { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--space) * -1); padding: 2px var(--space) var(--sp-1); }
.chips-scroll::-webkit-scrollbar { display: none; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-text); font-size: var(--fs-xs); font-weight: 700; }
.muted { color: var(--text-sub); }
.center { text-align: center; }
.empty-state { text-align: center; padding: 56px var(--sp-4); }
.empty-state > .icon { width: 48px; height: 48px; color: var(--brand); margin-block-end: var(--sp-2); }
.empty-state h2 { margin: 0 0 var(--sp-1); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-block: var(--sp-6) var(--sp-3); }
.section-head h2 { margin: 0; }
.section-head a { font-size: var(--fs-sm); color: var(--text-sub); text-decoration: none; font-weight: 600; }
.toast {
  position: fixed; inset-inline: var(--space); inset-block-end: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  margin: 0 auto; max-width: 420px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--text); color: var(--surface); text-align: center; box-shadow: var(--shadow-lg); font-size: var(--fs-sm);
}

/* 목록 행 (MY 메뉴·설정 등) */
.list-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-sm); }
.list-item { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: 0 var(--sp-4); color: var(--text); text-decoration: none; background: none; border: 0; width: 100%; text-align: start; cursor: pointer; }
.list-item + .list-item { border-block-start: 1px solid var(--line); }
.list-item .icon { color: var(--text-sub); }
.list-item .grow { flex: 1; }
.list-item .value { color: var(--text-sub); font-size: var(--fs-sm); }
.list-item .chev { color: var(--line-strong); }

/* 분할 라디오 (공개 설정·계산기 모드) */
.seg-radio { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--radius); background: var(--surface-2); }
.seg-radio label { position: relative; }
.seg-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-radio span { display: grid; place-items: center; min-height: 40px; border-radius: 9px; cursor: pointer; color: var(--text-sub); font-weight: 700; }
.seg-radio input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--brand-text); outline-offset: -2px; }
.seg-radio.small span { min-height: 34px; font-size: var(--fs-sm); }

/* 신고 창 · 숨김 안내 */
.report-reasons { border: 0; padding: 0; margin: 0 0 var(--sp-3); display: grid; gap: 2px; }
.report-reasons label { display: flex; align-items: center; gap: 10px; min-height: 44px; border-block-end: 1px solid var(--line); cursor: pointer; }
.report-reasons input { width: 20px; height: 20px; accent-color: var(--brand); }
#report-dialog textarea { width: 100%; margin-block-end: var(--sp-3); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); font: inherit; }
.blocked-note { margin: 0 0 var(--sp-3); padding: 12px 14px; border-radius: var(--radius); background: #F7E6DE; color: var(--danger); font-weight: 600; font-size: var(--fs-sm); }
.report-link { border: 0; background: none; padding: 0; color: var(--text-sub); font: inherit; font-size: var(--fs-sm); text-decoration: underline; cursor: pointer; }

/* 앱 스타일 확인 창 (confirm·prompt 대신) */
.ask-sheet {
  inset-block: auto 0; width: 100%; max-width: 480px; margin: 0 auto; padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  animation: ask-up .18s ease-out;
}
.ask-sheet::backdrop { background: rgb(40 30 22 / 45%); }
.ask-msg { margin: 0 0 18px; text-align: center; font-size: 1rem; font-weight: 600; line-height: 1.55; white-space: pre-line; }
.ask-input { width: 100%; min-height: 48px; margin-block-end: 16px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; }
.ask-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ask-actions .btn { min-height: 48px; }
.btn-danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
@keyframes ask-up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 720px) { .ask-sheet { inset-block: 0; border-radius: 22px; max-width: 400px; } }
@media (prefers-reduced-motion: reduce) { .ask-sheet { animation: none; } }

/* 하단 메뉴 이름도 손글씨 (한글·영문) */
:root:lang(ko) .tabbar a, :root:lang(en) .tabbar a { font-family: var(--font-hand); font-size: 0.75rem; font-weight: 400 !important; letter-spacing: 0; }
