:root {
  --bg: #ffffff;
  --bg2: #F2F4F6;
  --line: #E5E8EB;
  --text: #191F28;
  --text2: #6B7684;
  --text3: #B0B8C1;
  --accent: #FF3D8B;
  --accent-weak: #FFE3EF;
  --danger: #F04452;
  --r-card: 20px;
  --r-btn: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Hiragino Sans", "Noto Sans KR", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:active { transform: scale(0.97); }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: none; flex-direction: column; background: var(--bg); padding-top: var(--safe-t); }
.screen.active { display: flex; }
.screen.dark { background: #000; color: #fff; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 16px; }
.topbar .title { flex: 1; font-weight: 700; font-size: 17px; text-align: center; }
.topbar .spacer { width: 56px; }
.topbar.dark { color: #fff; }
.topbar .hint { flex: 1; text-align: center; font-size: 14px; opacity: .85; }
.brand { flex: 1; display: flex; flex-direction: column; }
.brand .logo { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; color: var(--accent); }
.brand .sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; font-size: 22px; display: grid; place-items: center; }
.pill { height: 36px; padding: 0 14px; border-radius: 18px; background: var(--bg2); font-weight: 700; font-size: 14px; white-space: nowrap; }
.pill.accent { background: var(--accent); color: #fff; }
.pill.danger { background: #FDE8EA; color: var(--danger); }

/* buttons */
.btn { height: 56px; border-radius: var(--r-btn); font-size: 17px; font-weight: 700; flex: 1; padding: 0 12px; }
.btn.primary { background: var(--accent); color: #fff; flex: 1.6; }
.btn.ghost { background: var(--bg2); color: var(--text); }
.bottom-cta { display: flex; gap: 8px; padding: 12px 16px calc(12px + var(--safe-b)); background: linear-gradient(to top, var(--bg) 70%, rgba(255,255,255,0)); }
.bottom-cta.three .btn.primary { flex: 1.2; }

/* log */
.log-list { flex: 1; overflow-y: auto; padding: 4px 16px 24px; -webkit-overflow-scrolling: touch; }
.day-head { font-size: 20px; font-weight: 800; margin: 18px 4px 10px; display: flex; align-items: baseline; gap: 8px; }
.day-head small { font-size: 13px; color: var(--text2); font-weight: 600; }
.log-item { display: grid; grid-template-columns: 52px 1fr; gap: 10px; margin-bottom: 14px; }
.log-time { font-size: 13px; color: var(--text2); font-weight: 600; padding-top: 6px; text-align: right; position: relative; }
.log-time::after { content: ""; position: absolute; right: -8px; top: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.log-card { background: var(--bg2); border-radius: var(--r-card); overflow: hidden; padding: 0; text-align: left; display: block; width: 100%; }
.log-card img { width: 100%; display: block; aspect-ratio: 4/5; object-fit: cover; background: var(--line); }
.log-card .cap { padding: 10px 14px 12px; font-size: 15px; font-weight: 600; }
.log-card .cap:empty { display: none; }
.empty { text-align: center; padding: 64px 16px; color: var(--text2); }
.empty .big { font-size: 64px; }
.empty h2 { color: var(--text); font-size: 20px; margin: 12px 0 8px; }
.empty p { white-space: pre-line; line-height: 1.6; margin: 0; }

/* camera */
.cam-wrap { flex: 1; position: relative; overflow: hidden; display: grid; place-items: center; }
#cam-video { width: 100%; height: 100%; object-fit: cover; }
#cam-video.mirror { transform: scaleX(-1); }
.cam-fallback p { white-space: pre-line; }
.cam-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 32px; text-align: center; font-size: 16px; line-height: 1.6; color: #ddd; }
.cam-controls { display: flex; align-items: center; justify-content: space-around; padding: 20px 16px calc(24px + var(--safe-b)); }
.shutter { width: 76px; height: 76px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.35); }
.shutter:disabled { opacity: .3; }
.round-btn.small { min-width: 64px; height: 44px; border-radius: 22px; background: rgba(255,255,255,.18); color: #fff; font-weight: 700; padding: 0 14px; }
.round-btn.small.big { background: var(--accent); }

/* editor */
.stage-wrap { flex: 1; position: relative; background: var(--bg2); display: grid; place-items: center; overflow: hidden; touch-action: none; }
#stage { display: block; touch-action: none; }
.toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(25,31,40,.86); color: #fff; padding: 9px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; max-width: calc(100% - 32px); text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; line-height: 1.45; }
.toast.show { opacity: 1; }
.tool-panel { padding: 10px 16px 4px; min-height: 112px; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.tool-tabs { display: flex; border-top: 1px solid var(--line); padding: 4px 4px var(--safe-b); }
.tool-tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--text3); font-size: 12px; font-weight: 700; }
.tool-tabs button i { font-style: normal; font-size: 22px; filter: grayscale(1); opacity: .55; }
.tool-tabs button.on { color: var(--text); }
.tool-tabs button.on i { filter: none; opacity: 1; }

.seg { display: flex; background: var(--bg2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; height: 40px; border-radius: 10px; font-weight: 700; font-size: 15px; color: var(--text2); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.row { display: flex; align-items: center; gap: 10px; }
.row label { font-size: 13px; font-weight: 700; color: var(--text2); min-width: 44px; }
.row .val { font-size: 13px; font-weight: 700; min-width: 40px; text-align: right; }
.row .btn-sm { height: 40px; padding: 0 12px; border-radius: 12px; background: var(--bg2); font-weight: 700; font-size: 14px; white-space: nowrap; }
.row .btn-sm.on { background: var(--accent); color: #fff; }
input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 32px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); margin-top: -11px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.tray::-webkit-scrollbar { display: none; }
.tray button { flex: 0 0 auto; width: 62px; height: 62px; border-radius: 16px; background: var(--bg2); display: grid; place-items: center; padding: 6px; }
.tray button img { max-width: 100%; max-height: 100%; }
.tray-label { font-size: 12px; color: var(--text2); font-weight: 600; }

/* share */
.share-main { flex: 1; overflow-y: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
#share-img { width: 100%; max-height: 62vh; object-fit: contain; border-radius: var(--r-card); background: var(--bg2); }
.caption { height: 52px; border-radius: 14px; border: 0; background: var(--bg2); padding: 0 16px; font: inherit; font-size: 16px; color: var(--text); outline: none; }
.caption:focus { box-shadow: 0 0 0 2px var(--accent); }
.saved-note { margin: 0; text-align: center; font-size: 14px; color: var(--accent); font-weight: 700; min-height: 20px; }

/* monetize: supporters + patron + A8 ad (log screen footer, not a screen) */
.monetize { padding: 10px 16px 4px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.supporters-line { font-size: 13px; font-weight: 700; color: var(--text2); text-decoration: none; text-align: center; }
.support-cta { display: block; width: 100%; text-align: center; background: var(--bg2); color: var(--text); border-radius: 16px; padding: 13px 8px; font-size: 14px; font-weight: 700; text-decoration: none; }
.a8-ad { text-align: center; }
.a8-ad .a8-pr { font-size: 11px; color: #888; margin-bottom: 4px; }
.a8-ad .a8-sp { display: none; }
.a8-ad img { max-width: 100%; }
@media (max-width: 640px) { .a8-ad .a8-pc { display: none; } .a8-ad .a8-sp { display: block; } }
