/* =====================================================================
   css/style.css — 붙붙(BooTBooT) 꾸밈 전부 (한 파일)
   순서: 1. 토큰 → 2. 바탕 → 3. 공통 부품 → 4. 화면 → 5. 효과
   - 한 대상의 규칙은 한 곳에만 있어요. 그 부품의 상태(고름, 누름, 못 누름)와 밤 테마도 그 부품 구역 안에 같이 둬요.
   - 고칠 때 맨 아래에 덧붙이지 말고, 그 부품 구역을 찾아서 고쳐요.
   - 크기는 모두 '앱 가로 360일 때' 기준 숫자에 var(--u)를 곱해서 써요 (어떤 폰이든 같은 비율).
   ===================================================================== */


/* =====================================================================
   1. 토큰 (디자인 값은 모두 여기서만 정해요)
   ===================================================================== */

/* ---------- 1-1. 낮 테마 (기본) ---------- */
:root {
  /* 화면 비율 맞추기: --u = 앱 실제 가로 / 360 */
  --design-w: 360;   /* 기준 앱 가로. 이 숫자를 줄이면 전부 커지고, 키우면 전부 작아짐 */
  --u: calc(min(100vw - 32px, 420px) / var(--design-w));   /* 1 디자인px (폰: 화면 가로 - 양옆 여백 16px씩) */
  --content-max: none;   /* 화면 내용 최대 가로 (태블릿, PC는 1-3에서 바뀜) */

  /* 색 */
  --bg: #ffffff;        /* 앱 바탕 */
  --grad-a: #FDE8F1;    /* 배경 그라데이션: 왼쪽 위 (분홍) */
  --grad-b: #EDE7FD;    /* 가운데 (연보라) */
  --grad-c: #E6F4D6;    /* 오른쪽 아래 (연두) */
  --bg-grad:
    radial-gradient(ellipse at 0% 0%, rgba(255, 196, 222, 0.55), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(206, 236, 160, 0.55), transparent 55%),
    linear-gradient(160deg, var(--grad-a) 0%, var(--grad-b) 50%, var(--grad-c) 100%);
  --grad-day: linear-gradient(160deg, #FDE8F1 0%, #EDE7FD 50%, #E6F4D6 100%);   /* 낮 배경 한 장 (밤 테마에서 고른 칸에 씀) */
  --grad-night: radial-gradient(ellipse at 0% 0%, rgba(130, 170, 255, 0.35), transparent 60%), linear-gradient(160deg, #2B2F45 0%, #262A3B 50%, #1E2130 100%);   /* 밤 배경 한 장 */
  --selected-grad: var(--grad-night);   /* 고른 칸 = 반대 테마의 배경 */
  --logo-a: #FF6FA8;    /* 시작 로고, 선택 고리 색 (낮: 분홍 → 보라) */
  --logo-b: #8B6CFF;
  --tile: rgba(255, 255, 255, 0.72);   /* 타일(카드): 반투명 흰색이라 그라데이션 위에서 떠 보임 */
  --ink: #1C1C1F;       /* 켜진 스위치, 탭 하이라이트 같은 진한 색 */
  --text: var(--ink);   /* 글씨 색 */
  --sub: #55555C;       /* 보조 글씨, 아직 안 고른 것 */
  --line: #66666E;      /* 홈 모양 그림 선 */
  --white: #FFFFFF;
  --field-bg: #F3F3F9;      /* 글꼴 입력칸 안쪽 */
  --field-border: #A9A9C8;  /* 글꼴 입력칸 테두리 */
  --divider: #D4D4E2;       /* 구분선, 사진 테두리 */
  --disabled: #A9A9B0;      /* 아직 누를 수 없는 버튼 */
  --selected-border: var(--ink);   /* 선택됨: 테두리 색 */
  --selected-bg: var(--white);     /* 선택됨: 안쪽 색 */
  --sel-ring: linear-gradient(135deg, var(--logo-a), var(--logo-b));   /* 선택 고리 (색 동그라미, 스티커 +, 펼치는 목록) */
  --sel-ring-w: calc(2 * var(--u));
  --cell-pick: linear-gradient(160deg, #9DE8D6 0%, #8EC8F5 100%);       /* 고른 홈 타일 안의 칸 (밤: 민트 → 파랑) */
  --cell-pick-day: linear-gradient(160deg, #FFB3CF 0%, #FFE08A 100%);   /* (낮: 분홍 → 노랑) */
  --glass: rgba(255, 255, 255, 0.5);          /* 유리 느낌 칸 (반투명 + 뒤 흐림) */
  --glass-strong: rgba(255, 255, 255, 0.62);
  --glass-line: rgba(255, 255, 255, 0.75);

  /* 크기: 모든 버튼, 탭, 칸, 색 동그라미가 --btn 하나를 씀. 이 줄만 바꾸면 전부 같이 바뀜 */
  --min-touch: 36px;    /* 누르는 칸의 최소 크기 (작은 폰에서도 이보다 작아지지 않음) */
  --btn: max(var(--min-touch), calc(36 * var(--u)));
  --tab-h: var(--btn);      /* 편집 탭 높이 */
  --swatch: var(--btn);     /* 색 동그라미 크기 */
  --tap-gap: max(10px, calc(12 * var(--u)));   /* 나란히 놓인 버튼 사이 (옆 버튼을 같이 누르지 않게 10px 이상) */
  --btn-font: calc(12 * var(--u));     /* 버튼 글씨. 제목을 뺀 모든 글씨도 이 크기 */
  --btn-icon: calc(var(--btn-font) * 1.3);   /* 버튼 안 아이콘 = 글씨의 1.3배 (아이콘과 글씨가 같은 무게로 보이게) */
  --btn-pad: calc(12 * var(--u));      /* 글씨 버튼 양옆 여백 */
  --icon-stroke: 3.6;   /* 버튼 아이콘 선 굵기 */
  --field-h: var(--btn);           /* 글꼴 입력칸 높이 = 버튼 크기 */
  --field-font: var(--btn-font);   /* 입력칸 글씨 = 버튼 글씨 */
  --divider-gap: calc(4 * var(--u));     /* 탭 줄과 위아래 구분선 사이 */
  --bottom-space: calc(18 * var(--u));   /* 편집 화면 맨 아래 여백 */
  --ad-gap: calc(12 * var(--u));         /* 광고 칸 위 여백 */
  --glyph-scale: 4;     /* 홈 미리보기 칸의 모양 그림 크기 (타일 그림의 몇 배) */
  --badge-size: calc(18 * var(--u));     /* 사진 선택: 고른 순서 숫자 동그라미 */
  --badge-font: calc(9 * var(--u));

  /* 막대(슬라이더): 끈 만큼 채워지는 둥근 막대 + 그림자 있는 흰 손잡이 */
  --range-track: calc(4 * var(--u));     /* 막대 두께 */
  --range-thumb: calc(18 * var(--u));    /* 손잡이 크기 */
  --range-fill: var(--ink);              /* 채워진 부분 (왼쪽) */
  --range-rest: rgba(28, 28, 31, 0.12);  /* 남은 부분 (오른쪽) */
  --range-knob: #FFFFFF;
  --range-shadow: 0 calc(1 * var(--u)) calc(4 * var(--u)) rgba(28, 28, 31, 0.28), 0 0 0 calc(0.5 * var(--u)) rgba(28, 28, 31, 0.08);
  --range-ring: 0 0 0 calc(6 * var(--u)) rgba(28, 28, 31, 0.10);   /* 잡고 끄는 동안 생기는 옅은 원 */

  --ui: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color-scheme: light;
}

/* ---------- 1-2. 밤 테마: 네이비 바탕 (js/0-core/theme.js가 <html data-theme="night">를 붙임) ---------- */
html[data-theme="night"] {
  --bg: #292D3E;
  --bg-grad:
    radial-gradient(ellipse at 0% 0%, rgba(130, 170, 255, 0.20), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(137, 221, 255, 0.14), transparent 55%),
    linear-gradient(160deg, #2B2F45 0%, #262A3B 50%, #1E2130 100%);
  --selected-grad: var(--grad-day);
  --logo-a: #82AAFF;    /* 밤: 파랑 → 하늘색 */
  --logo-b: #89DDFF;
  --tile: rgba(52, 57, 82, 0.78);
  --ink: #4A5280;       /* 네이비 */
  --text: #D0D4EE;      /* 밝은 회청색 글씨 */
  --sub: #8F97C0;
  --line: #A6ACCD;
  --white: #EEF0FA;     /* 밝은 색 (스위치 손잡이 등) */
  --field-bg: #1E2130;
  --field-border: #4E5579;
  --divider: #3A3F58;
  --disabled: #3A3F58;
  --selected-border: #A6ACCD;   /* 네이비 바탕에서 잘 보이게 밝은 회청색 */
  --selected-bg: #2F3348;
  --glass: rgba(41, 45, 62, 0.5);
  --glass-strong: rgba(41, 45, 62, 0.66);
  --glass-line: rgba(166, 172, 205, 0.22);
  --range-fill: #A6ACCD;
  --range-rest: rgba(255, 255, 255, 0.14);
  --range-knob: #EEF0FA;
  --range-shadow: 0 calc(1 * var(--u)) calc(4 * var(--u)) rgba(0, 0, 0, 0.5);
  --range-ring: 0 0 0 calc(6 * var(--u)) rgba(166, 172, 205, 0.18);
  color-scheme: dark;
}

/* ---------- 1-3. 기기별 (js/0-core/display.js가 <html data-device="mobile|tablet|desktop">를 실시간으로 바꿈) ---------- */
/* 모바일: 1-1 기본값 그대로 (화면 전체가 앱) */
/* 태블릿: 화면 전체, 버튼·글씨는 조금 크게, 내용은 가운데 720px까지 */
html[data-device="tablet"] {
  --u: calc(min(100vw, 900px) / 600);
  --content-max: 720px;
}
/* PC: 창 크기 그대로, 크기는 창 높이에 맞춤, 내용은 가운데 960px까지 */
html[data-device="desktop"] {
  --u: clamp(1px, calc(100vh / 680), 1.3px);
  --content-max: 960px;
}


/* =====================================================================
   2. 바탕
   ===================================================================== */
* {
  box-sizing: border-box;
  scrollbar-width: none; -ms-overflow-style: none;   /* 스크롤 막대 숨기기: 손가락(PC는 마우스)으로 끌어서 넘겨봄 */
  -webkit-tap-highlight-color: transparent;          /* 폰에서 누를 때 생기는 파란/회색 네모 없애기 */
}
*::-webkit-scrollbar { display: none; }
/* 누르거나 고를 때 생기는 네모 테두리는 모든 곳에서 끔 (막대는 마우스로 눌러도 :focus-visible이 켜져서 함께 끔) */
:focus, :focus-visible { outline: none; }
[hidden] { display: none !important; }   /* 클래스의 display보다 항상 이기게 (숨김이 안 풀리도록) */
html, body { height: 100%; height: 100dvh; }   /* dvh: 주소창을 뺀 실제 보이는 높이 */
body {
  margin: 0; padding-inline: 16px; padding-block: 0; box-sizing: border-box;
  display: flex; justify-content: center;
  background: var(--bg-grad); background-attachment: fixed;
  color: var(--text); font-family: var(--ui); font-size: var(--btn-font);
}
html[data-device="tablet"] body, html[data-device="desktop"] body { padding-inline: 0; }
img { max-width: 100%; }
button { font-family: inherit; color: inherit; }
h1, h2 { margin: 0; text-wrap: balance; }
.dragging, .dragging * { user-select: none; -webkit-user-select: none; }   /* 마우스로 끌어서 넘기는 동안 글꼴 선택 막기 */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 앱 틀: 배경은 body의 그라데이션이 비쳐 보임 */
.app { position: relative; width: 100%; max-width: 420px; height: 100%; background: transparent; overflow: hidden; display: flex; flex-direction: column; }
html[data-device="tablet"] .app, html[data-device="desktop"] .app { max-width: none; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: var(--content-max); margin-inline: auto; }   /* 넓은 화면에서는 가운데 정렬 */

/* 위 줄: 왼쪽 뒤로/취소, 가운데 제목, 오른쪽 다음/저장 (사진 선택, 편집하기, 설정, 결과 보기 공통) */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--tap-gap); padding: calc(calc(20 * var(--u)) + env(safe-area-inset-top, 0px)) calc(20 * var(--u)) calc(12 * var(--u)); }   /* 노치만큼 아래로 */
.top h1 { font-size: calc(17 * var(--u)); font-weight: 600; text-align: center; }
.top > :first-child { justify-self: start; }
.top > :last-child { justify-self: end; }
.top-title { display: flex; flex-direction: column; align-items: center; gap: calc(2 * var(--u)); }   /* 제목 + 그 아래 작은 글 (사진 선택: 몇 장 골랐는지) */
.top-title h1 { font-size: calc(17 * var(--u)); font-weight: 600; text-align: center; }


/* =====================================================================
   3. 공통 부품
   ===================================================================== */

/* ---------- 3-1. 버튼: 바탕(틀) 없이 아이콘이나 글씨만 보임. 누를 수 있는 칸 크기(--btn)는 그대로 ---------- */
.icon-btn { width: var(--btn); height: var(--btn); border: 0; border-radius: calc(var(--btn) / 2); background: transparent; color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.icon-btn svg { stroke: var(--text); stroke-width: var(--icon-stroke); width: var(--btn-icon); height: var(--btn-icon); }
.icon-btn svg circle { fill: var(--text); }   /* 설정 아이콘의 동그라미 손잡이: 꽉 찬 동그라미 */
.icon-btn:disabled { color: var(--disabled); cursor: default; }   /* 사진을 다 고르기 전의 다음(→) 버튼 */
.icon-btn:disabled svg { stroke: var(--disabled); }
.icon-btn:disabled svg circle { fill: var(--disabled); }
/* 저장 버튼의 작은 "AD" 표시: 저장하면 광고가 나온다는 것을 미리 알려줌 */
.icon-btn[data-ad] { position: relative; }
.icon-btn[data-ad]::after { content: 'AD'; position: absolute; top: calc(-6 * var(--u)); right: calc(-8 * var(--u)); padding: 0 calc(3 * var(--u)); border-radius: calc(4 * var(--u)); background: var(--white); color: var(--ink); border: 1px solid var(--ink); font-size: calc(7 * var(--u)); font-weight: 700; line-height: 1.4; }
/* 글씨 버튼 (꾸미기, 저장): 바탕이 없어도 눌러야 할 버튼인 게 보이게 글씨를 진하게 */
.primary, .secondary { flex-shrink: 0; padding: 0 var(--btn-pad); white-space: nowrap; height: var(--btn); border: 0; border-radius: calc(var(--btn) / 2); background: transparent; color: var(--text); font-size: var(--btn-font); font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: calc(3 * var(--u)); }
.primary:disabled { color: var(--disabled); cursor: default; }
.primary svg, .secondary svg { width: var(--btn-icon); height: var(--btn-icon); }
.link-btn { border: 0; border-radius: calc(var(--btn) / 2); background: transparent; color: var(--text); font-size: var(--btn-font); font-weight: 700; cursor: pointer; height: var(--btn); padding: 0 var(--btn-pad); flex-shrink: 0; }   /* 바꾸기 */
/* 글씨 앞에 그림(+)이 붙는 버튼: 그림 선은 글씨 색을 따라감 */
.icon-label { display: inline-flex; align-items: center; gap: calc(3 * var(--u)); }
.icon-label svg { stroke: currentColor; width: var(--btn-icon); height: var(--btn-icon); flex-shrink: 0; }

/* ---------- 3-2. 고르기 버튼 (비율, 크기, 글꼴 이름, 언어, 위치, 저장 형식 등) ----------
   고르면 틀이나 하이라이트 없이 글씨만 더 굵고 진하게. 안 고른 것은 보통 굵기의 회색 글씨 (탭 줄과 같은 규칙) */
.pills { display: flex; gap: var(--tap-gap); flex-wrap: wrap; align-items: center; }
.pill { position: relative; min-width: calc(36 * var(--u)); height: var(--btn); padding: 0 var(--btn-pad); border: calc(2 * var(--u)) solid transparent; border-radius: calc(var(--btn) / 2); background: var(--tile); font-size: var(--btn-font); font-weight: 500; color: var(--sub); cursor: pointer; font-variant-numeric: tabular-nums; }
.pill[aria-pressed="true"] { font-weight: 800; color: var(--text); background: transparent; border-color: transparent; }
.panel .pill { background: transparent; }   /* 편집 메뉴의 고르기 버튼은 바탕 없이 글씨만 */
/* 행동 버튼 (+ 글꼴 파일): 고르는 버튼이 아니라서 글씨 진하게 */
.pill.dashed { border: 0; background: transparent; color: var(--text); font-weight: 700; }

/* ---------- 3-3. 탭 (편집 화면): 고른 탭은 바탕 없이 글씨만 더 굵고 진하게 ---------- */
.tabs { display: flex; gap: var(--tap-gap); margin: 0 calc(16 * var(--u)); padding: var(--divider-gap) 0; border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); overflow-x: auto; }   /* 위아래 구분선, 양 끝은 16px씩 띄움 */
.tab { flex-shrink: 0; height: var(--tab-h); padding: 0 calc(8 * var(--u)); border: 0; border-radius: calc(var(--btn) / 2); background: transparent; font-size: var(--btn-font); font-weight: 500; color: var(--sub); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--text); font-weight: 800; }

/* ---------- 3-4. 글꼴 입력칸 (글꼴 입력칸, 가로·세로 숫자 칸, 파일 이름 칸) ---------- */
.field { height: var(--field-h); border: 1px solid var(--field-border); border-radius: calc(6 * var(--u)); background: var(--field-bg); padding: 0 calc(8 * var(--u)); font-size: var(--field-font); font-family: inherit; color: var(--text); }
/* 쓰는 중: 바탕을 두 겹으로 그려서 테두리 자리에만 선택 고리 그라데이션이 보이게 (테두리가 두꺼워진 만큼 안쪽 여백을 줄여 글씨가 안 움직임) */
.field:focus { border: calc(2 * var(--u)) solid transparent; padding: 0 calc(8 * var(--u) - (2 * var(--u) - 1px)); background: linear-gradient(var(--selected-bg), var(--selected-bg)) padding-box, var(--sel-ring) border-box; }
.num-input { width: calc(72 * var(--u)); padding: 0 calc(6 * var(--u)); font-variant-numeric: tabular-nums; }   /* 숫자 칸만 좁게 */

/* ---------- 3-5. 선택 고리: 고른 것 주변에 얇은 그라데이션 테두리 (색 동그라미, 스티커 +, 펼치는 목록) ----------
   칸 위에 얇은 테두리 모양(::after)을 하나 덮어서 그림. 칸의 바탕색은 건드리지 않음 */
.gsel-trigger::after,
.sw[aria-pressed="true"]::after,
.stk-add[aria-pressed="true"]::after, .stk-add:active::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: var(--sel-ring-w); pointer-events: none;
  background: var(--sel-ring);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}

/* ---------- 3-6. 펼치는 목록 (설정: 언어, 위치, 저장 형식) — js/4-screens/glide.js의 GlideSelect ---------- */
.gsel { position: relative; }
.gsel-trigger {
  position: relative; width: 100%; height: var(--btn); padding: 0 calc(14 * var(--u)); display: flex; align-items: center; justify-content: space-between; gap: calc(8 * var(--u));
  border: 1px solid var(--glass-line); border-radius: calc(var(--btn) / 2); background: var(--glass); color: var(--text);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  font-size: var(--btn-font); font-weight: 600; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
}
.gsel-trigger::after { inset: -1px; opacity: 0; transition: opacity 0.2s; }   /* 선택 고리: 평소에는 안 보이고, 올리거나 펼쳤을 때만 */
.gsel-trigger:hover, .gsel.open .gsel-trigger { border-color: transparent; }
.gsel-trigger:hover::after, .gsel.open .gsel-trigger::after { opacity: 1; }
.gsel-chev { width: var(--btn-icon); height: var(--btn-icon); stroke: var(--sub); transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.gsel.open .gsel-chev { transform: rotate(180deg); }
.gsel-list.pills {
  position: absolute; left: 0; right: 0; top: calc(100% + 6 * var(--u)); z-index: 10;
  flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: calc(2 * var(--u)); padding: calc(6 * var(--u));
  border: 1px solid var(--glass-line); border-radius: calc(18 * var(--u)); background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 calc(12 * var(--u)) calc(32 * var(--u)) rgba(28, 28, 31, 0.16);
  opacity: 0; visibility: hidden; transform: translateY(calc(-6 * var(--u))) scale(0.97); transform-origin: top center;
  transition: opacity 0.18s, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.25s;
}
html[data-theme="night"] .gsel-list.pills { box-shadow: 0 calc(12 * var(--u)) calc(32 * var(--u)) rgba(0, 0, 0, 0.45); }
.gsel.open .gsel-list.pills { opacity: 1; visibility: visible; transform: none; transition: opacity 0.18s, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s; }
.gsel-list .pill { width: 100%; text-align: left; background: transparent; border-color: transparent; border-radius: calc(12 * var(--u)); }

/* ---------- 3-7. 글라이드 하이라이트: 고른 버튼 뒤에 하나가 미끄러지듯 따라감 — js/4-screens/glide.js ----------
   지금 보이는 곳은 설정의 테마 버튼뿐 (탭 줄, 고르기 버튼은 글씨만 굵게 하는 규칙이라 숨김) */
.glide { position: relative; }
.glide > :not(.glide-hl) { position: relative; z-index: 1; }
.glide-hl {
  position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none;
  border-radius: calc(var(--btn) / 2); background: var(--selected-bg);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), width 0.32s cubic-bezier(0.22, 1, 0.36, 1), height 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s;
}
.glide-hl.instant { transition: none; }
.tabs .glide-hl, .pills.glide:not(#set-theme) > .glide-hl { display: none; }

/* ---------- 3-8. 켜기/끄기 스위치: 글씨 크기에 맞춤 (높이 = 글씨의 1.8배, 가로 = 높이의 1.7배). 누르는 칸은 줄 전체 ---------- */
.switch input {
  --sw-pad: calc(2 * var(--u)); --sw-h: calc(var(--btn-font) * 1.8); --sw-w: calc(var(--sw-h) * 1.7); --sw-knob: calc(var(--sw-h) - var(--sw-pad) * 2);
  appearance: none; -webkit-appearance: none; position: relative; flex-shrink: 0; margin: 0;
  width: var(--sw-w); height: var(--sw-h); border-radius: calc(var(--sw-h) / 2); background: var(--disabled); cursor: pointer; transition: background .15s;
}
.switch input::after { content: ''; position: absolute; top: var(--sw-pad); left: var(--sw-pad); width: var(--sw-knob); height: var(--sw-knob); border-radius: 50%; background: var(--white); transition: left .15s; }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { left: calc(var(--sw-w) - var(--sw-knob) - var(--sw-pad)); }   /* 켜지면 손잡이가 오른쪽 끝으로 */

/* ---------- 3-9. 막대 (모서리, 간격, 크기, 테두리 두께): 모두 같은 규칙 ----------
   막대 칸 높이 = 버튼 크기 (손잡이 그림은 작아도 손가락이 닿는 칸은 넓게)
   채워지는 길이(--fill)는 JS가 값에 맞춰 넣어 줌 */
input[type="range"] { -webkit-appearance: none; appearance: none; height: var(--btn); background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: var(--range-track); border-radius: var(--range-track); background: linear-gradient(to right, var(--range-fill) var(--fill, 0%), var(--range-rest) var(--fill, 0%)); }
input[type="range"]::-moz-range-track { height: var(--range-track); border-radius: var(--range-track); background: var(--range-rest); }
input[type="range"]::-moz-range-progress { height: var(--range-track); border-radius: var(--range-track); background: var(--range-fill); }   /* 파이어폭스는 채움을 따로 그려 줌 */
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; box-sizing: border-box; width: var(--range-thumb); height: var(--range-thumb); border-radius: 50%; border: 0; background: var(--range-knob); box-shadow: var(--range-shadow); margin-top: calc((var(--range-track) - var(--range-thumb)) / 2); transition: transform .15s ease, box-shadow .15s ease; }
input[type="range"]::-moz-range-thumb { box-sizing: border-box; width: var(--range-thumb); height: var(--range-thumb); border-radius: 50%; border: 0; background: var(--range-knob); box-shadow: var(--range-shadow); transition: transform .15s ease, box-shadow .15s ease; }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); box-shadow: var(--range-shadow), var(--range-ring); }
input[type="range"]:active::-moz-range-thumb { transform: scale(1.12); box-shadow: var(--range-shadow), var(--range-ring); }
.slider { display: grid; grid-template-columns: calc(64 * var(--u)) minmax(0,1fr) calc(36 * var(--u)); align-items: center; gap: calc(10 * var(--u)); font-size: var(--btn-font); font-weight: 500; }
.slider input { width: 100%; accent-color: var(--ink); }
.slider output { text-align: right; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 3-10. 색 동그라미 (팔레트 .sw, 글꼴 카드의 지금 색 .tcard-dot): 같은 크기, 같은 테두리 ---------- */
.sw, .tcard-dot { width: var(--swatch); height: var(--swatch); border-radius: 50%; border: calc(1.5 * var(--u)) solid #C4C4CA; padding: 0; cursor: pointer; }
html[data-theme="night"] .sw, html[data-theme="night"] .tcard-dot { border-color: #4E5579; }
.sw { position: relative; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.sw svg { width: calc(var(--swatch) * 0.45); height: calc(var(--swatch) * 0.45); }   /* 색 직접 고르기(+) 아이콘 */
.sw[aria-pressed="true"]::after { inset: calc(-4 * var(--u)); padding: calc(2 * var(--u)); border-radius: 50%; }   /* 바깥에 살짝 띄운 선택 고리 */
.tcard-dot { background: var(--white); }
/* 색 없음: 흰 동그라미에 빗금 한 줄 */
.tcard-dot.none, .sw[data-color="none"] { background: linear-gradient(135deg, transparent 46%, #E85D5D 46%, #E85D5D 54%, transparent 54%), var(--white); }

/* ---------- 3-11. 알림, 덮개 (저장 중, 결과 보기) ---------- */
.toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100% - calc(32 * var(--u))); padding: calc(12 * var(--u)) calc(18 * var(--u)); border-radius: calc(14 * var(--u)); background: var(--ink); color: var(--white); font-size: var(--btn-font); font-weight: 500; text-align: center; z-index: 8; }
.busy { position: absolute; inset: 0; background: rgba(28,28,31,.35); display: flex; align-items: center; justify-content: center; z-index: 5; }
.busy-box { min-width: calc(170 * var(--u)); padding: calc(24 * var(--u)) calc(28 * var(--u)); border-radius: calc(20 * var(--u)); background: var(--white); display: flex; flex-direction: column; align-items: center; gap: calc(14 * var(--u)); font-size: var(--btn-font); font-weight: 600; }
html[data-theme="night"] .busy-box { background: #2F3348; }
.spin { width: calc(28 * var(--u)); height: calc(28 * var(--u)); border-radius: 50%; border: calc(3 * var(--u)) solid var(--tile); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result { position: absolute; inset: 0; background: var(--bg-grad); z-index: 7; display: flex; flex-direction: column; }
.result .imgbox { flex: 1; min-height: 0; overflow: auto; padding: 0 calc(16 * var(--u)) calc(52 * var(--u)); display: flex; justify-content: center; align-items: flex-start; }
.result img { max-width: 100%; height: auto; display: block; margin: auto 0; }
.result p { margin: 0; padding: calc(12 * var(--u)) calc(20 * var(--u)) calc(20 * var(--u)); font-size: var(--btn-font); line-height: 1.5; color: var(--sub); text-align: center; }

/* ---------- 3-12. 광고: 홈 하단 배너 칸 (화면 맨 아래 고정) ---------- */
.ad-slot { flex-shrink: 0; margin-top: var(--ad-gap); padding-bottom: env(safe-area-inset-bottom, 0px); background: transparent; }


/* =====================================================================
   4. 화면
   ===================================================================== */

/* ---------- 4-1. 홈 ---------- */
.home-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: calc(calc(20 * var(--u)) + env(safe-area-inset-top, 0px)) calc(24 * var(--u)) calc(24 * var(--u)); gap: calc(28 * var(--u)); overflow-y: auto; }
.home .title-row { display: flex; justify-content: space-between; align-items: center; padding-top: calc(16 * var(--u)); }
.home h1 { font-size: calc(28 * var(--u)); font-weight: 700; letter-spacing: -0.5px; }
html[data-theme="night"] .home h1 { background: linear-gradient(90deg, #C9CEEA, #89DDFF); -webkit-background-clip: text; background-clip: text; color: transparent; }   /* 앱 이름: 회청색 → 하늘색 */
.sec-head { display: flex; flex-direction: column; gap: calc(4 * var(--u)); }
.sec-head h2 { font-size: calc(18 * var(--u)); font-weight: 600; }
/* 콜라주 모양 타일 */
.layouts { display: flex; flex-direction: column; gap: calc(12 * var(--u)); }   /* 줄(lrow)을 위에서 아래로 쌓음 */
.lrow { display: flex; gap: var(--tap-gap); }   /* 한 줄 안의 모양 묶음들 (예: 4장, 6장) */
.lgroup { display: flex; flex-direction: column; gap: calc(8 * var(--u)); }
.lgroup .lab { font-size: var(--btn-font); font-weight: 600; color: var(--sub); }
.lgroup .row { display: flex; gap: var(--tap-gap); }
.ltile { position: relative; overflow: hidden; width: 88px; height: 88px; border: 2px solid transparent; border-radius: 18px; background: var(--tile); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }   /* 화면 비율과 상관없이 원래 크기 그대로 */
.ltile > :not(.pixel-canvas) { position: relative; z-index: 1; }   /* 픽셀 반짝임(5-2) 위에 그림 */
.ltile[aria-pressed="true"] { background: var(--selected-bg); }   /* 고른 타일: 테두리 없이 바탕 + 픽셀 반짝임 */
.ltile .b, .drop-glyph .b { border: 2px solid var(--line); border-radius: 5px; }   /* 타일 안의 작은 칸 */
/* 고른 모양의 칸 (타일 안 + 큰 미리보기 그림): 낮은 분홍 → 노랑, 밤은 민트 → 파랑. border-box: 투명 테두리 자리까지 한 장으로 칠함 */
.ltile[aria-pressed="true"] .b, .drop-glyph .b { background: var(--cell-pick-day) border-box; border-color: transparent; }
html[data-theme="night"] .ltile[aria-pressed="true"] .b, html[data-theme="night"] .drop-glyph .b { background: var(--cell-pick) border-box; }
/* 미리보기 칸: 아무것도 안 고름(none) / 사진 한 장(single) / 콜라주 모양(collage) */
.pick-card { padding: calc(20 * var(--u)); border-radius: calc(22 * var(--u)); background: var(--tile); display: flex; flex-direction: column; gap: calc(16 * var(--u)); }
.pick-card .primary { align-self: center; }
.drop { position: relative; overflow: hidden; width: 100%; aspect-ratio: 1 / 1; border: calc(2 * var(--u)) dashed #8A8A92; border-radius: calc(14 * var(--u)); display: flex; text-align: center; transition: background .15s; }
html[data-theme="night"] .drop { border-color: #676E95; }
html[data-device="tablet"] .drop { aspect-ratio: 4 / 3; }    /* 넓은 화면: 너무 길어지지 않게 가로로 넓적하게 */
html[data-device="desktop"] .drop { aspect-ratio: 16 / 7; }
.drop > :not(.pixel-canvas) { position: relative; z-index: 1; }
.drop[data-mode="single"] { background: var(--bg-grad); }   /* 한 장 고름: 낮은 앱 배경 파스텔, 밤은 반대 테마(낮) 파스텔. 점선 테두리는 그대로 */
html[data-theme="night"] .drop[data-mode="single"] { background: var(--selected-grad); }
.drop[data-mode="collage"] { background: var(--white); }
html[data-theme="night"] .drop[data-mode="collage"] { background: #2F3348; }
.drop strong { font-size: var(--btn-font); font-weight: 600; }
.drop[data-mode="single"] .drop-main svg { stroke: var(--text); }   /* 고른 칸 위 아이콘: 글씨와 같은 색 */
html[data-theme="night"] .drop[data-mode="single"] strong { color: #1C1C1F; }   /* 밤: 밝은 파스텔 칸 위는 진한 글씨, 아이콘 */
html[data-theme="night"] .drop[data-mode="single"] .drop-main svg { stroke: #1C1C1F; }
.drop-main { flex: 1; border: 0; background: transparent; border-radius: calc(12 * var(--u)); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(8 * var(--u)); padding: calc(16 * var(--u)); }
.drop-preview { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(14 * var(--u)); padding: calc(16 * var(--u)); }
.drop-glyph { width: 200px; height: 190px; display: flex; align-items: center; justify-content: center; }
.drop-glyph > span { transform: scale(var(--glyph-scale)); }
.drop-glyph .b { border-width: calc(2px * 2.2 / var(--glyph-scale)); }   /* 모양을 키워도 테두리는 예전과 같은 굵기로 보이게 키운 만큼 나눔 */
.drop-close { align-self: flex-end; margin: calc(-12 * var(--u)) calc(-12 * var(--u)) calc(-16 * var(--u)) 0; width: var(--btn); height: var(--btn); border: 0; border-radius: calc(var(--btn) / 2); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 1; }
.drop-close svg { stroke: var(--text); stroke-width: var(--icon-stroke); width: var(--btn-icon); height: var(--btn-icon); }
.drop-close span { width: var(--btn); height: var(--btn); border-radius: calc(var(--btn) / 2); background: transparent; display: flex; align-items: center; justify-content: center; }
/* 꾸미기 기능 칩 */
.chips { display: flex; align-items: center; gap: calc(8 * var(--u)); flex-wrap: wrap; font-size: var(--btn-font); color: var(--sub); }
.chips-label { flex-basis: 100%; }
.chip { display: inline-flex; align-items: center; padding: calc(6 * var(--u)) calc(12 * var(--u)); border-radius: calc(16 * var(--u)); background: var(--bg); font-weight: 500; color: #3A3A40; }
html[data-theme="night"] .chip { background: rgba(137, 221, 255, 0.12); color: #89DDFF; }

/* ---------- 4-2. 사진 선택 ---------- */
.picker .count { font-size: var(--btn-font); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--sub); }   /* 제목 아래 "몇 장 선택" */
.grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: calc(3 * var(--u)); align-content: start; }
html[data-device="tablet"] .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
html[data-device="desktop"] .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.cell { position: relative; aspect-ratio: 1; border: 0; padding: 0; cursor: pointer; overflow: hidden; background: var(--tile); }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell.on img { opacity: .55; }
.cell.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(6 * var(--u)); font-size: var(--btn-font); font-weight: 600; color: #3A3A40; text-align: center; padding: calc(8 * var(--u)); }
html[data-theme="night"] .cell.add { color: var(--text); }
.badge { position: absolute; right: calc(6 * var(--u)); bottom: calc(6 * var(--u)); width: var(--badge-size); height: var(--badge-size); border-radius: calc(var(--badge-size) / 2); border: calc(1.5 * var(--u)) solid var(--white); background: rgba(28,28,31,.25); color: var(--white); font-size: var(--badge-font); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.cell.on .badge { background: var(--ink); }

/* ---------- 4-3. 편집하기: 한 화면 안에 다 들어감 (위아래로 넘기지 않음) ---------- */
#s-edit { overflow: hidden; }
.edit-main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-start; padding-bottom: calc(var(--bottom-space) + env(safe-area-inset-bottom, 0px)); }
.edit-main > :not(.stage) { flex-shrink: 0; }   /* 위 줄, 탭 줄, 메뉴 칸은 눌려서 찌그러지지 않게 */
/* 사진 칸 = 사진 크기만큼 (크기 계산은 editor-screen.js의 fit: 화면 높이의 58%까지, 메뉴를 빼고 남은 자리까지). 메뉴는 사진 바로 아래 */
.stage { flex: 0 0 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: calc(8 * var(--u)) calc(16 * var(--u)); overflow: auto; }
.stage.tall { flex: 1 1 0; align-items: flex-start; }   /* 이어붙이기(세로로 긴 사진)는 남는 자리를 다 쓰고 위아래로 넘겨봄 */
.stage canvas { display: block; flex-shrink: 0; touch-action: none; box-shadow: 0 0 0 1px var(--divider); }   /* 사진 네 변의 얇은 테두리 */
html[data-theme="night"] .stage canvas { box-shadow: 0 0 0 1px var(--divider), 0 calc(8 * var(--u)) calc(28 * var(--u)) rgba(0, 0, 0, 0.35); }
.canvas-wrap { position: relative; flex-shrink: 0; line-height: 0; }   /* 사진 + 위에 떠 있는 버튼 묶음 */
.canvas-wrap .view-btn { position: absolute; top: calc(8 * var(--u)); right: calc(8 * var(--u)); }   /* 크게 보기: 사진 안 오른쪽 위 */
.canvas-wrap .reset-btn { position: absolute; top: calc(8 * var(--u)); left: calc(8 * var(--u)); }   /* 되돌리기: 사진 안 왼쪽 위 */
.canvas-wrap .icon-btn svg { stroke: #FFFFFF; filter: drop-shadow(0 0 calc(2 * var(--u)) rgba(0, 0, 0, 0.6)); }   /* 사진에 묻히지 않게 흰 아이콘 + 옅은 그림자 */
/* 고른 글꼴, 스티커의 크기 막대와 지우기. 아무것도 안 골랐을 때는 자리를 차지하지 않음 */
.selbar { min-height: calc(var(--btn) + calc(4 * var(--u))); margin: 0 calc(16 * var(--u)); padding: calc(2 * var(--u)) 0; display: flex; align-items: center; gap: calc(10 * var(--u)); }
.selbar:has(> .sel-tools[hidden]) { min-height: 0; padding: 0; }
.sel-tools { flex: 1; display: flex; align-items: center; gap: var(--tap-gap); min-width: 0; }
.sel-size { flex: 1; min-width: 0; display: flex; align-items: center; gap: calc(8 * var(--u)); font-size: var(--btn-font); font-weight: 500; }
.sel-size input { flex: 1; min-width: 0; accent-color: var(--ink); }
/* 메뉴 칸: 내용만큼만 차지 (최대 45%) */
.panel { flex: none; height: auto; max-height: 45%; padding: calc(8 * var(--u)) calc(16 * var(--u)); display: flex; flex-direction: column; gap: calc(8 * var(--u)); overflow-y: auto; }
/* 크기(px) 탭 */
.size-row { display: flex; align-items: center; gap: var(--tap-gap); flex-wrap: wrap; }
.small-note { font-size: var(--btn-font); color: var(--sub); }
.size-row .small-note { font-size: var(--field-font); }
/* 글꼴 탭: 내용 전체를 살짝 아래로, 색 팝업이 칸 밖으로 나와도 잘리지 않게 */
#p-text { position: relative; padding-top: calc(16 * var(--u)); overflow: visible; }
.text-row { display: flex; gap: var(--tap-gap); align-items: center; }
.text-row .field { flex: 1; min-width: 0; }
#text-new { border: 0; background: transparent; }   /* 새 글꼴(+) */
/* 글꼴 색 고를 대상 카드 3개 (배경, 글꼴, 테두리): 고르면 글씨만 더 굵게 */
.tcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--tap-gap); }
.tcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: calc(6 * var(--u)); padding: calc(4 * var(--u)) 0; border: calc(2 * var(--u)) solid transparent; border-radius: calc(14 * var(--u)); background: var(--white); font-size: var(--btn-font); font-weight: 500; color: var(--sub); }   /* 테두리 자리는 남겨서 팝업이 열릴 때 크기가 안 바뀜 */
html[data-theme="night"] .tcard { background: #2F3348; }
.tcard[aria-pressed="true"] { font-weight: 800; color: var(--text); }
/* 색 팝업: 글꼴 패널 위에 떠 있는 유리 창 (위치는 JS가 누른 카드 바로 아래로 정함) */
.tpop { position: absolute; z-index: 3; padding: calc(10 * var(--u)); border: 1px solid var(--glass-line); border-radius: calc(14 * var(--u)); background: var(--glass-strong); -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5); box-shadow: 0 calc(4 * var(--u)) calc(16 * var(--u)) rgba(28, 28, 31, .15); }
.tpop .pills { flex-wrap: nowrap; }
/* 글꼴 테두리 두께: 막대와 두께 숫자를 한 줄에 (숫자는 오른쪽 끝). 음수 margin: 카드 바로 아래에 붙임 */
.stroke-row { display: flex; align-items: center; gap: calc(8 * var(--u)); margin-top: calc(-12 * var(--u)); }
.stroke-head { order: 2; flex-shrink: 0; display: flex; align-items: center; }
.stroke-out { font-size: var(--btn-font); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stroke-row input { flex: 1; min-width: 0; }
/* 스티커 탭 */
.stk-btn { width: var(--btn); height: var(--btn); border: 0; border-radius: calc(5 * var(--u)); background: transparent; cursor: pointer; padding: calc(2 * var(--u)); }
.stk-btn svg { width: 100%; height: 100%; }
.stk-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: calc(3 * var(--u)); display: block; -webkit-touch-callout: none; user-select: none; pointer-events: none; }   /* 내 사진 스티커: 꾹 눌러 지울 때 폰 메뉴가 안 뜨게 */
.stk-add { position: relative; border: calc(2 * var(--u)) solid transparent; display: inline-flex; align-items: center; justify-content: center; }   /* "+" 내 사진 가져오기 */
.stk-add svg { width: var(--btn-icon); height: var(--btn-icon); }
.stk-add[aria-pressed="true"], .stk-add:active { background: var(--selected-bg); }
.stk-add[aria-pressed="true"]::after, .stk-add:active::after { inset: calc(-2 * var(--u)); }   /* 원래 테두리 자리 위에 선택 고리 */

/* ---------- 4-4. 설정 ---------- */
#set-save { width: auto; padding: 0 calc(12 * var(--u)); align-self: center; }
.settings { flex: 1; overflow-y: auto; padding: calc(4 * var(--u)) calc(20 * var(--u)) calc(24 * var(--u)); display: flex; flex-direction: column; gap: calc(24 * var(--u)); }
.set-main { flex: none; display: flex; flex-direction: column; gap: calc(24 * var(--u)); }
.set-block { display: flex; flex-direction: column; gap: calc(8 * var(--u)); }
.set-title { font-size: var(--btn-font); font-weight: 600; color: var(--sub); letter-spacing: calc(0.2 * var(--u)); }
.set-group { background: var(--tile); border-radius: calc(18 * var(--u)); padding: calc(8 * var(--u)) calc(16 * var(--u)); display: flex; flex-direction: column; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: calc(12 * var(--u)); min-height: calc(52 * var(--u)); font-size: var(--btn-font); font-weight: 500; cursor: pointer; }
.set-col { display: flex; flex-direction: column; gap: calc(10 * var(--u)); padding: calc(12 * var(--u)) 0; font-size: var(--btn-font); font-weight: 500; }
.set-row + .set-row, .set-row + .set-col, .set-col + .set-row { border-top: 1px solid #C9C9CF; }
html[data-theme="night"] .set-row + .set-row, html[data-theme="night"] .set-row + .set-col, html[data-theme="night"] .set-col + .set-row { border-top-color: #3A3F58; }
/* 정보 줄 (개인정보처리방침, 에셋 출처) */
.set-link { width: 100%; border: 0; background: transparent; color: var(--text); font-family: inherit; text-align: left; padding: 0; }
.set-link svg { width: var(--btn-icon); height: var(--btn-icon); stroke: var(--sub); flex-shrink: 0; }
/* 테마 버튼: 아이콘만 있는 동그라미. 고른 것은 테두리 없이 그 테마 색으로 채움 (글라이드 하이라이트가 미끄러지며 칠함)
   - 낮: 분홍 → 보라 파스텔 + 진한 아이콘 / 밤: 거의 검정 + 밝은 아이콘 */
#set-theme { --theme-on-day: linear-gradient(135deg, #FFC2DA 0%, #D9CCFF 100%); --theme-on-night: linear-gradient(135deg, #14162A 0%, #1B1E33 100%); }
#set-theme .pill { display: inline-flex; align-items: center; justify-content: center; gap: calc(6 * var(--u)); width: var(--btn); min-width: var(--btn); padding: 0; font-weight: 600; color: inherit; }
#set-theme .pill[aria-pressed="true"] { color: #1C1C1F; }
html[data-theme="night"] #set-theme .pill[aria-pressed="true"] { color: #EEF0FA; }
#set-theme svg { width: var(--btn-icon); height: var(--btn-icon); }
#set-theme .glide-hl { background: var(--theme-on-day); }
html[data-theme="night"] #set-theme .glide-hl { background: var(--theme-on-night); box-shadow: 0 calc(4 * var(--u)) calc(14 * var(--u)) rgba(0, 0, 0, 0.35); }
/* 개인정보처리방침, 에셋 출처 글 (js/4-screens/legal-sheet.js) */
.legal-sheet { position: absolute; inset: 0; z-index: 15; display: flex; flex-direction: column; background: var(--bg-grad); animation: sheet-in 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.legal-sheet[hidden] { display: none; }
.legal-sheet .top { width: 100%; max-width: var(--content-max); margin-inline: auto; }
.legal-close svg { width: var(--btn-icon); height: var(--btn-icon); }
.legal-body { width: 100%; max-width: var(--content-max); margin-inline: auto; flex: 1; overflow-y: auto; padding: calc(4 * var(--u)) calc(24 * var(--u)) calc(32 * var(--u) + env(safe-area-inset-bottom, 0px)); font-size: calc(13 * var(--u)); line-height: 1.7; color: var(--text); }
.legal-body h3 { margin: calc(20 * var(--u)) 0 calc(4 * var(--u)); font-size: calc(14 * var(--u)); }
.legal-body p { margin: 0 0 calc(8 * var(--u)); }
.legal-body ul { margin: 0 0 calc(8 * var(--u)); padding-left: calc(18 * var(--u)); }
.legal-body a { color: var(--logo-b); }
.legal-meta { color: var(--sub); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(calc(16 * var(--u))); } to { opacity: 1; transform: none; } }


/* =====================================================================
   5. 효과
   ===================================================================== */

/* ---------- 5-1. 시작 로고 (js/4-screens/intro.js) ----------
   0.00~0.70초 카메라 그리기 → 0.70초 셔터 번쩍 → 0.85~1.35초 사진 모양 그리기 → 1.55초부터 커지며 사라짐, 홈 메뉴 올라옴 */
.intro { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(14 * var(--u)); background: var(--bg-grad); cursor: pointer; }
.intro-logo { width: calc(132 * var(--u)); height: calc(132 * var(--u)); overflow: visible; }
.intro-stop-a { stop-color: var(--logo-a); }
.intro-stop-b { stop-color: var(--logo-b); }
.intro-logo g { fill: none; stroke: url(#intro-grad); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 calc(4 * var(--u)) color-mix(in srgb, var(--logo-b) 45%, transparent)); }   /* 흔들림 없이 은은한 빛만 */
.intro-logo g > * { stroke-dasharray: 1; stroke-dashoffset: 1; }
.intro-cam { transform-origin: 60px 65px; animation: intro-cam-out 0.4s 0.85s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.intro-cam > * { animation: intro-draw 0.6s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.intro-cam > :nth-child(2) { animation-delay: 0.08s; }
.intro-cam > :nth-child(3) { animation-delay: 0.2s; }
.intro-cam > :nth-child(4) { animation-delay: 0.32s; }
.intro-flash { fill: var(--white); opacity: 0; transform-origin: 60px 65px; animation: intro-flash 0.45s 0.68s ease-out forwards; }
html[data-theme="night"] .intro-flash { fill: #FFFFFF; }
.intro-photo { opacity: 0; transform-origin: 60px 60px; animation: intro-photo-in 0.01s 0.9s forwards; }
.intro-photo > * { animation: intro-draw 0.45s 0.9s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.intro-photo > :nth-child(2) { animation-delay: 1.02s; }
.intro-photo > :nth-child(3) { animation-delay: 1.12s; }
.intro-word { font-size: calc(15 * var(--u)); font-weight: 700; letter-spacing: calc(4 * var(--u)); background: linear-gradient(90deg, var(--logo-a), var(--logo-b)); -webkit-background-clip: text; background-clip: text; color: transparent; opacity: 0; transform: translateY(calc(6 * var(--u))); animation: intro-word 0.5s 1s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.intro-out { animation: intro-fade 0.45s cubic-bezier(0.65, 0, 0.35, 1) forwards; }   /* 끝날 때: 액자가 커지면서 사라짐 (= 홈 메뉴로 펼쳐지는 느낌) */
.intro-out .intro-logo { animation: intro-zoom 0.45s cubic-bezier(0.65, 0, 0.35, 1) forwards; }
.intro-skip { animation: intro-fade 0.22s ease-out forwards; }
@keyframes intro-draw { to { stroke-dashoffset: 0; } }
@keyframes intro-flash { 0% { opacity: 0; transform: scale(0.4); } 30% { opacity: 0.95; } 100% { opacity: 0; transform: scale(5); } }
@keyframes intro-cam-out { to { opacity: 0; transform: scale(0.82); } }
@keyframes intro-photo-in { to { opacity: 1; } }
@keyframes intro-word { to { opacity: 1; transform: none; } }
@keyframes intro-fade { to { opacity: 0; visibility: hidden; } }
@keyframes intro-zoom { to { transform: scale(3.2); } }
/* 홈 메뉴가 아래에서 차례로 올라옴 */
.home-enter .home-body > * { animation: home-rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.home-enter .home-body > :nth-child(2) { animation-delay: 0.06s; }
.home-enter .home-body > :nth-child(3) { animation-delay: 0.12s; }
.home-enter .home-body > :nth-child(4) { animation-delay: 0.18s; }
.home-enter .home-body > :nth-child(n+5) { animation-delay: 0.24s; }
@keyframes home-rise { from { opacity: 0; transform: translateY(calc(18 * var(--u))) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- 5-2. 픽셀 반짝임: 홈 타일, 사진 선택 상자 (js/4-screens/pixel-card.js) ---------- */
.pixel-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* ---------- 5-3. 클릭 스파크 (js/4-screens/click-spark.js) ---------- */
.click-spark { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; }

/* ---------- 5-4. 누름 손맛: 누르면 살짝 눌리고, PC에서 올리면 살짝 뜸 ---------- */
.icon-btn, .primary, .secondary, .link-btn, .pill, .tab, .ltile { transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s; }
.icon-btn:active:not(:disabled), .primary:active:not(:disabled), .secondary:active, .pill:active, .ltile:active { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover:not(:disabled), .primary:hover:not(:disabled), .secondary:hover { transform: translateY(-1px); }
}

/* ---------- 5-5. 동작 줄이기: 기기에서 켜면 움직임을 끔 ---------- */
@media (prefers-reduced-motion: reduce) {
  .drop, .switch input, .switch input::after, .glide-hl, .gsel-list.pills, .gsel-chev { transition: none; }
  .spin { animation: none; }
}
