/* ── 테마 ── 인스타 웹 색을 따른다. 시스템 설정에 맞춰 밝게/어둡게 */
:root {
  --bg: #fff;
  --bg-elev: #fff;
  --bg-hover: #f2f2f2;
  --bg-input: #efefef;
  --border: #dbdbdb;
  --text: #000;
  --text2: #737373;
  --link: #0095f6;
  --link-hover: #1877f2;
  --danger: #ed4956;
  --like: #ff3040;
  --ring: linear-gradient(45deg, #f9ce34 0%, #ee2a7b 50%, #6228d7 100%);
  --ring-seen: #c7c7c7;
  --overlay: rgba(0, 0, 0, .65);
  --shadow: 0 4px 24px rgba(0, 0, 0, .15);
  --radius: 8px;
  --side-w: 244px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-elev: #262626;
    --bg-hover: #1a1a1a;
    --bg-input: #262626;
    --border: #262626;
    --text: #f5f5f5;
    --text2: #a8a8a8;
    --ring-seen: #363636;
    --shadow: 0 4px 24px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/18px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img, video { display: block; max-width: 100%; }
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 16px; height: 16px; }
.ic.fill { fill: currentColor; stroke: none; }
[data-icon] { display: inline-flex; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ── 레이아웃 ── */
#app { display: flex; min-height: 100vh; }
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w);
  display: flex; flex-direction: column;
  padding: 8px 12px 16px; border-right: 1px solid var(--border);
  background: var(--bg); z-index: 50;
}
#main { flex: 1; margin-left: var(--side-w); min-width: 0; padding-bottom: 32px; }
.logo { font-family: "Grand Hotel", cursive; font-size: 30px; line-height: 1; padding: 22px 12px 18px; display: block; }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.nav-btn { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: var(--radius); font-size: 16px; }
.nav-btn:hover { background: var(--bg-hover); }
.nav-btn.active { font-weight: 700; }
.nav-btn.active .ic { stroke-width: 2.6; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--text2); padding: 8px 12px 4px; }
.accounts-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; min-height: 80px; }
.account-folder-header { display: flex; justify-content: space-between; font-size: 11px; color: var(--text2); padding: 10px 12px 4px; text-transform: uppercase; letter-spacing: .03em; }
.account-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); cursor: pointer; }
.account-item:hover { background: var(--bg-hover); }
.account-item.active { background: var(--bg-hover); }
.account-item.active .account-name { font-weight: 700; }
.account-item.is-hidden { opacity: .55; }
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-meta { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-refresh { opacity: 0; color: var(--text2); padding: 4px; border-radius: 50%; }
.account-item:hover .account-refresh, .account-refresh:focus-visible { opacity: 1; }
.account-refresh:hover { color: var(--text); }

.sidebar-footer { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.side-row { display: flex; gap: 6px; }
.side-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 10px; border-radius: var(--radius); background: var(--bg-input); font-weight: 600; font-size: 13px; }
.side-btn .ic { width: 18px; height: 18px; }
.side-btn:hover { filter: brightness(.95); }
.side-btn.primary { background: var(--link); color: #fff; }
.side-btn.primary:hover { background: var(--link-hover); filter: none; }
.side-btn.icon-only { flex: none; width: 40px; padding: 9px 0; }
.side-btn:disabled { opacity: .5; cursor: default; }
.sidebar-overlay { display: none; }

.task-panel { display: none; border-top: 1px solid var(--border); padding: 10px 4px 4px; max-height: 30vh; overflow-y: auto; }
.task-panel-title { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.task-item { padding: 6px 0; }
.task-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; }
.task-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-percent { color: var(--text2); flex: none; }
.task-sub { font-size: 11px; color: var(--text2); margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-bar { height: 3px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.task-bar-fill { height: 100%; background: var(--link); transition: width .3s; }
.task-bar-indeterminate { background: linear-gradient(90deg, transparent, var(--link), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: slide 1.2s linear infinite; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

#mobile-top, #bottom-nav { display: none; }
.view { display: none; }
.view.active { display: block; }

/* ── 아바타 / 스토리 링 ── */
.avatar { position: relative; flex: none; border-radius: 50%; overflow: hidden; background: var(--bg-input); display: inline-flex; align-items: center; justify-content: center; color: var(--text2); font-weight: 600; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.s32 { width: 32px; height: 32px; font-size: 13px; }
.avatar.s44 { width: 44px; height: 44px; font-size: 16px; }
.ring { position: relative; flex: none; border-radius: 50%; padding: 2px; background: var(--ring); display: inline-flex; }
.ring.seen { background: var(--ring-seen); }
.ring > .avatar { border: 2px solid var(--bg); }
.ring.none { background: transparent; }
button.ring, a.ring { cursor: pointer; }

/* ── 홈 ── */
.home-wrap { max-width: 640px; margin: 0 auto; padding: 48px 20px; display: flex; flex-direction: column; gap: 16px; }
.home-hero { text-align: center; padding: 24px 0 8px; }
.home-logo { font-family: "Grand Hotel", cursive; font-size: 56px; line-height: 1.1; }
.home-hero p { color: var(--text2); margin: 10px 0 18px; font-size: 15px; line-height: 1.5; }
.home-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.home-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.home-card-title { font-weight: 700; font-size: 15px; }
.home-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.home-row .text-input { flex: 1; min-width: 160px; }
.home-hint { font-size: 13px; color: var(--text2); line-height: 1.5; }
.home-hint.ok { color: #2fb344; }
.home-hint.bad { color: var(--danger); }
.file-input { flex: 1; min-width: 0; font-size: 13px; color: var(--text2); }
.markdown-body { line-height: 1.6; font-size: 14px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 18px 0 8px; line-height: 1.3; }
.markdown-body h1 { font-size: 20px; }
.markdown-body h2 { font-size: 17px; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body pre { margin: 8px 0; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; }
.markdown-body code { background: var(--bg-input); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.markdown-body pre { background: var(--bg-input); padding: 12px; border-radius: var(--radius); overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body a { color: var(--link); }
.wiki-list { display: flex; flex-wrap: wrap; gap: 6px; }
.wiki-link { padding: 6px 12px; border-radius: 999px; background: var(--bg-input); font-size: 13px; }

/* ── 피드 ── */
.feed-col { max-width: 470px; margin: 0 auto; padding: 24px 0; }
.stories-tray { display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 16px; margin-bottom: 8px; scrollbar-width: none; }
.stories-tray::-webkit-scrollbar { display: none; }
.stories-tray:empty { display: none; }
.tray-item { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 66px; flex: none; }
.tray-item .avatar { width: 56px; height: 56px; font-size: 20px; }
.tray-name { font-size: 12px; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

.post-card { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.pc-head { display: flex; align-items: center; gap: 10px; padding: 0 4px 12px; }
.pc-who { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.pc-user { font-weight: 600; }
.pc-user:hover { opacity: .6; }
.pc-time { color: var(--text2); }
.pc-sub { width: 100%; font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--bg-input); color: var(--text2); }
.badge.del { background: var(--danger); color: #fff; }
.pc-media { border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.pc-actions { display: flex; align-items: center; gap: 14px; padding: 10px 4px 6px; }
.pc-actions .spacer { flex: 1; }
.pc-actions .act { display: inline-flex; align-items: center; gap: 6px; }
.pc-actions .cnt { font-weight: 600; font-size: 14px; }
.pc-actions button:hover, .pc-actions a:hover { color: var(--text2); }
.pc-likes { font-weight: 600; padding: 0 4px; }
.pc-caption { padding: 6px 4px 0; line-height: 18px; white-space: pre-wrap; word-break: break-word; }
.pc-caption.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.more-link { color: var(--text2); padding: 2px 4px 0; }
.pc-comments { display: block; color: var(--text2); padding: 6px 4px 0; }
.list-sentinel { height: 1px; }
.loading-row { display: flex; justify-content: center; padding: 24px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bg-input); border-top-color: var(--text2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 캐러셀 ── */
.carousel { position: relative; background: #000; overflow: hidden; }
.car-track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.car-track::-webkit-scrollbar { display: none; }
.car-slide { position: relative; flex: 0 0 100%; height: 100%; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; }
.car-slide img, .car-slide video { width: 100%; height: 100%; object-fit: cover; }
.carousel.contain .car-slide img, .carousel.contain .car-slide video { object-fit: contain; }
.car-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .85); color: #000; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); z-index: 2; }
.car-arrow .ic { width: 18px; height: 18px; stroke-width: 2.6; }
.car-arrow.prev { left: 8px; }
.car-arrow.next { right: 8px; }
.car-arrow[hidden] { display: none; }
.car-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; pointer-events: none; z-index: 2; }
.car-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .45); transition: background .2s; }
.car-dots span.on { background: #fff; }
.car-count { position: absolute; top: 12px; right: 12px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 999px; z-index: 2; }
.media-btn { position: absolute; right: 12px; bottom: 12px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 3; }
.media-btn .ic { width: 15px; height: 15px; }
.play-hint { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; color: #fff; opacity: .9; pointer-events: none; display: none; filter: drop-shadow(0 0 8px rgba(0, 0, 0, .5)); }
.paused .play-hint { display: block; }

/* ── 프로필 ── */
.profile-wrap { max-width: 935px; margin: 0 auto; padding: 30px 20px 0; }
.profile-head { display: flex; gap: 28px; align-items: center; padding: 0 0 24px 40px; }
.ph-avatar .avatar { width: 150px; height: 150px; font-size: 52px; }
.ph-avatar.ring { padding: 3px; }
.ph-avatar.ring > .avatar { border-width: 4px; }
.ph-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.ph-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ph-handle { font-size: 20px; font-weight: 400; margin-right: 12px; word-break: break-all; }
.ph-btn { padding: 7px 14px; border-radius: var(--radius); background: var(--bg-input); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.ph-btn:hover { filter: brightness(.94); }
.ph-btn .ic { width: 16px; height: 16px; }
.ph-stats { display: flex; gap: 32px; list-style: none; font-size: 16px; }
.ph-stats b { font-weight: 600; }
.ph-name { font-weight: 600; }
.ph-bio { white-space: pre-wrap; word-break: break-word; line-height: 1.45; margin-top: -8px; }
.ph-archive { font-size: 12px; color: var(--text2); }
.highlights { display: flex; gap: 28px; overflow-x: auto; padding: 4px 0 28px 40px; scrollbar-width: none; }
.highlights::-webkit-scrollbar { display: none; }
.highlights:empty { display: none; }
.hl-item { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 87px; flex: none; }
.hl-item .ring { background: var(--ring-seen); padding: 2px; }
.hl-item .avatar { width: 77px; height: 77px; }
.hl-item.deleted { opacity: .5; }
.hl-title { font-size: 12px; font-weight: 600; max-width: 87px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-tabs { display: flex; justify-content: center; gap: 60px; border-top: 1px solid var(--border); }
.profile-tabs button { display: flex; align-items: center; gap: 6px; height: 52px; font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--text2); border-top: 1px solid transparent; margin-top: -1px; }
.profile-tabs button .ic { width: 14px; height: 14px; }
.profile-tabs button.active { color: var(--text); border-top-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid-item { position: relative; aspect-ratio: 3 / 4; background: var(--bg-input); overflow: hidden; cursor: pointer; }
.grid.stories .grid-item { aspect-ratio: 9 / 16; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; }
.grid-icon { position: absolute; top: 8px; right: 8px; color: #fff; filter: drop-shadow(0 0 3px rgba(0, 0, 0, .6)); display: flex; gap: 4px; }
.grid-icon .ic { width: 20px; height: 20px; }
.grid-views { position: absolute; left: 8px; bottom: 8px; color: #fff; font-weight: 600; display: flex; align-items: center; gap: 4px; filter: drop-shadow(0 0 3px rgba(0, 0, 0, .7)); }
.grid-views .ic { width: 16px; height: 16px; }
.grid-date { position: absolute; left: 8px; top: 8px; background: rgba(255, 255, 255, .92); color: #000; border-radius: 6px; padding: 4px 6px; font-size: 11px; font-weight: 700; line-height: 1.15; text-align: center; }
.grid-hover { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); color: #fff; display: none; align-items: center; justify-content: center; gap: 24px; font-weight: 700; font-size: 16px; }
.grid-hover span { display: flex; align-items: center; gap: 6px; }
.grid-hover .ic { width: 20px; height: 20px; }
@media (hover: hover) { .grid-item:hover .grid-hover { display: flex; } }
.grid-del { position: absolute; left: 8px; bottom: 8px; }

.empty-state { display: none; text-align: center; padding: 80px 20px; color: var(--text2); }
.empty-state.active { display: block; }
.empty-state .big { width: 62px; height: 62px; margin: 0 auto 16px; border: 2px solid var(--text); color: var(--text); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.empty-state h2 { color: var(--text); font-size: 24px; font-weight: 800; margin-bottom: 10px; }
.grid-empty { grid-column: 1 / -1; }

/* ── 오버레이 공통 (게시물 / 릴스 / 스토리) ── */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 200; display: none; align-items: center; justify-content: center; }
.overlay.open { display: flex; }
.overlay-close { position: absolute; top: 14px; right: 16px; color: #fff; z-index: 5; padding: 6px; }
.overlay-close .ic { width: 28px; height: 28px; }
.overlay-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, .9); color: #000; display: flex; align-items: center; justify-content: center; z-index: 5; }
.overlay-nav .ic { width: 20px; height: 20px; stroke-width: 2.6; }
.overlay-nav.prev { left: 20px; }
.overlay-nav.next { right: 20px; }
.overlay-nav[hidden] { display: none; }
body.no-scroll { overflow: hidden; }

/* 게시물 모달 */
.post-modal { display: flex; background: var(--bg-elev); max-width: min(1200px, calc(100vw - 140px)); height: min(90vh, 900px); border-radius: 4px; overflow: hidden; }
@media (prefers-color-scheme: dark) { .post-modal { background: #000; } }
.pm-media { background: #000; height: 100%; display: flex; align-items: center; }
.pm-media .carousel { height: 100%; }
.pm-side { width: 405px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--border); min-height: 0; }
.pm-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.pm-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.pm-caption { display: flex; gap: 12px; }
.pm-caption-text { white-space: pre-wrap; word-break: break-word; line-height: 18px; }
.pm-caption-time { font-size: 12px; color: var(--text2); margin-top: 8px; }
.pm-info { font-size: 12px; color: var(--text2); line-height: 1.7; }
.pm-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-tags a, .pm-tags span { font-size: 12px; color: var(--link); }
.pm-foot { border-top: 1px solid var(--border); padding: 6px 16px 14px; }
.pm-foot .pc-actions { padding-left: 0; padding-right: 0; }
.pm-foot .pc-likes { padding: 0; }
.pm-date { font-size: 12px; color: var(--text2); margin-top: 6px; }
.pm-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tool-btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; background: var(--bg-input); font-size: 12px; font-weight: 600; }
.tool-btn .ic { width: 14px; height: 14px; }
.tool-btn:hover { filter: brightness(.94); }

/* 릴스 */
.reels-overlay { background: #000; }
.reels-scroll { height: 100%; width: 100%; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.reels-scroll::-webkit-scrollbar { display: none; }
.reel { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px 0; }
.reel-stage { position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100vw; background: #111; border-radius: 8px; overflow: hidden; }
.reel-stage video, .reel-stage img { width: 100%; height: 100%; object-fit: cover; }
.reel-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 60px 16px 18px; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); color: #fff; }
.reel-user { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.reel-caption { font-size: 14px; line-height: 18px; white-space: pre-wrap; word-break: break-word; max-height: 54px; overflow: hidden; }
.reel-caption.open { max-height: 40vh; overflow-y: auto; }
.reel-audio { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 8px; opacity: .9; }
.reel-audio .ic { width: 14px; height: 14px; }
.reel-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .25); }
.reel-progress i { display: block; height: 100%; width: 0; background: #fff; }
.reel-actions { display: flex; flex-direction: column; align-items: center; gap: 18px; color: var(--text); align-self: flex-end; padding-bottom: 12px; }
.reels-overlay .reel-actions { color: #fff; }
.reel-act { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.reel-act .ic { width: 26px; height: 26px; }
.reel-mute { top: 14px; right: 14px; bottom: auto; }

/* 스토리 */
.story-overlay { background: #1a1a1a; }
.story-stage { position: relative; height: min(100vh - 32px, 900px); aspect-ratio: 9 / 16; max-width: 100vw; background: #000; border-radius: 8px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.story-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.story-media img, .story-media video { width: 100%; height: 100%; object-fit: contain; }
.story-top { position: absolute; left: 0; right: 0; top: 0; padding: 12px 12px 40px; background: linear-gradient(rgba(0, 0, 0, .55), transparent); z-index: 3; color: #fff; }
.story-bars { display: flex; gap: 3px; margin-bottom: 10px; }
.story-bars span { flex: 1; height: 2px; background: rgba(255, 255, 255, .35); border-radius: 2px; overflow: hidden; }
.story-bars i { display: block; height: 100%; width: 0; background: #fff; }
.story-head { display: flex; align-items: center; gap: 8px; }
.story-head .who { font-weight: 600; font-size: 14px; }
.story-head .when { opacity: .75; font-size: 13px; }
.story-head .spacer { flex: 1; }
.story-head button { color: #fff; padding: 4px; }
.story-head button .ic { width: 20px; height: 20px; }
.story-tap { position: absolute; top: 70px; bottom: 0; width: 35%; z-index: 2; }
.story-tap.left { left: 0; }
.story-tap.right { right: 0; width: 65%; }
.story-foot { position: absolute; left: 12px; right: 12px; bottom: 14px; z-index: 3; color: #fff; font-size: 12px; opacity: .85; display: flex; gap: 8px; align-items: center; }
.story-foot .ic { width: 14px; height: 14px; }

/* ── 모달 (설정/통계 등) ── */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 300; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-elev); border-radius: 12px; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 20px 20px; box-shadow: var(--shadow); }
.modal.wide { max-width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.modal-header h2 { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { color: var(--text); padding: 2px; }
.modal-hint { font-size: 13px; color: var(--text2); margin-bottom: 14px; line-height: 1.5; }
.modal-scroll { max-height: 64vh; overflow-y: auto; }
.input-group { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: 13px; font-weight: 600; }
.input-row { display: flex; align-items: center; background: var(--bg-input); border-radius: var(--radius); border: 1px solid var(--border); }
.input-prefix { padding: 0 0 0 12px; color: var(--text2); }
.input-row .text-input { border: 0; background: transparent; }
.text-input, .settings-input { width: 100%; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font: inherit; }
.settings-input { width: 110px; flex: none; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.btn { padding: 8px 16px; border-radius: var(--radius); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--link); color: #fff; }
.btn-primary:hover { background: var(--link-hover); }
.btn-secondary { background: var(--bg-input); }
.btn-secondary:hover { filter: brightness(.94); }
.btn:disabled { opacity: .5; cursor: default; }
.danger-btn { width: 100%; padding: 10px; border-radius: var(--radius); color: var(--danger); font-weight: 600; border: 1px solid var(--border); margin-top: 12px; }
.danger-btn:hover { background: var(--bg-hover); }
#progress-section { display: none; margin-top: 4px; }
.progress-info { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.prog-bar-wrap { height: 4px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.prog-bar-fill { height: 100%; width: 0; background: var(--ring); transition: width .3s; }
.progress-log { margin-top: 8px; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text2); min-height: 16px; word-break: break-all; }
.settings-card { border: 1px solid var(--border); border-radius: 10px; padding: 4px 14px; margin-bottom: 12px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
label.settings-row { cursor: pointer; }
.settings-title { font-weight: 600; }
.settings-desc { font-size: 12px; color: var(--text2); line-height: 1.45; }
.settings-inline { display: flex; gap: 6px; padding: 4px 0; }
.settings-readout { font-size: 12px; color: var(--text2); padding: 4px 0 10px; }
.radio-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--bg-input); font-size: 12px; cursor: pointer; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-slider { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .2s; }
.switch-slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked + .switch-slider { background: var(--text); }
.switch input:checked + .switch-slider::after { transform: translateX(16px); }
@media (prefers-color-scheme: dark) { .switch input:checked + .switch-slider::after { background: #000; } }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--link); outline-offset: 2px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--bg-input); font-size: 13px; font-weight: 600; }
.chip.active { background: var(--text); color: var(--bg); }
.stats-chart-wrap { position: relative; height: 280px; }
.stats-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.summary-card { flex: 1; min-width: 120px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.sc-label { font-size: 12px; color: var(--text2); }
.sc-val { font-size: 20px; font-weight: 700; margin-top: 2px; }
.sc-diff { font-size: 12px; margin-top: 2px; color: var(--text2); }
.sc-diff.up { color: #2fb344; }
.sc-diff.down { color: var(--danger); }
.empty-note { text-align: center; padding: 32px; color: var(--text2); }

/* 상세 / 변경 기록 */
.detail-section { margin-bottom: 16px; }
.detail-section-title { font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13px; }
.detail-label { color: var(--text2); }
.detail-value { word-break: break-word; white-space: pre-wrap; }
.detail-value a { color: var(--link); }
.detail-mute { color: var(--text2); }
.detail-json { font: 11.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg-input); padding: 10px; border-radius: var(--radius); max-height: 320px; overflow: auto; white-space: pre; }
.change-filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.change-filter-select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text); font: inherit; }
.change-entry { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.change-header { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.change-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; padding: 3px 0; }
.change-label { font-weight: 600; min-width: 80px; }
.change-from { color: var(--text2); }
.change-text { white-space: pre-wrap; word-break: break-word; max-width: 100%; }
.change-arrow { color: var(--text2); }
.change-delta { font-size: 12px; font-weight: 600; }
.change-delta.up { color: #2fb344; }
.change-delta.down { color: var(--danger); }
.change-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

#toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); background: #262626; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 500; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.skeleton { background: var(--bg-input); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ── 좁은 화면 ── */
@media (max-width: 1160px) {
  :root { --side-w: 220px; }
}
@media (max-width: 900px) {
  .post-modal { flex-direction: column; height: auto; max-height: 92vh; max-width: calc(100vw - 24px); overflow-y: auto; }
  .pm-media { height: auto; }
  .pm-media .carousel { height: auto; width: 100%; }
  .pm-side { width: 100%; border-left: 0; }
  .pm-body { overflow: visible; }
  .overlay-nav { display: none; }
}
@media (max-width: 767px) {
  #sidebar { transform: translateX(-100%); transition: transform .25s; width: 280px; box-shadow: var(--shadow); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  body.nav-open #sidebar { transform: none; }
  body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 40; }
  #main { margin-left: 0; padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  #mobile-top { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 30; }
  #mobile-top .logo { padding: 0; font-size: 28px; }
  .icon-btn { padding: 6px; }
  #bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(50px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: var(--bg); z-index: 30; justify-content: space-around; align-items: center; }
  #bottom-nav > * { padding: 10px 14px; }
  #bottom-nav .active .ic { stroke-width: 2.6; }
  .feed-col { padding: 8px 0; }
  .post-card { border-bottom: 0; }
  .pc-head { padding: 0 12px 10px; }
  .pc-media { border-radius: 0; border-left: 0; border-right: 0; }
  .pc-actions, .pc-likes, .pc-caption, .pc-comments { padding-left: 12px; padding-right: 12px; }
  .stories-tray { padding: 8px 12px 12px; border-bottom: 1px solid var(--border); }
  .profile-wrap { padding: 16px 0 0; }
  .profile-head { padding: 0 16px 16px; gap: 20px; align-items: flex-start; }
  .ph-avatar .avatar { width: 77px; height: 77px; font-size: 28px; }
  .ph-avatar.ring > .avatar { border-width: 3px; }
  .ph-stats { gap: 0; font-size: 13px; justify-content: space-between; max-width: 260px; }
  .ph-stats li { display: flex; flex-direction: column-reverse; align-items: center; white-space: nowrap; color: var(--text2); }
  .ph-stats b { color: var(--text); font-size: 15px; }
  .ph-handle { font-size: 18px; }
  .highlights { padding: 0 16px 16px; gap: 14px; }
  .hl-item { width: 64px; }
  .hl-item .avatar { width: 56px; height: 56px; }
  .profile-tabs { gap: 0; justify-content: space-around; }
  .profile-tabs button { letter-spacing: 0; }
  .grid { gap: 2px; }
  .overlay-close { top: 8px; right: 8px; }
  .reel { padding: 0; gap: 0; position: relative; }
  .reel-stage { border-radius: 0; height: 100%; width: 100%; aspect-ratio: auto; }
  .reel-actions { position: absolute; right: 10px; bottom: 90px; color: #fff; }
  .story-overlay { background: #000; }
  .story-stage { height: 100%; width: 100%; aspect-ratio: auto; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* 위키 (markdown.js가 그린다) */
.home-wiki-title { font-weight: 700; font-size: 15px; margin: 8px 0; }
.home-wiki-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.home-wiki-item summary { cursor: pointer; font-weight: 600; }
.home-wiki-content { margin-top: 8px; }
.mention { color: #00376b; }
@media (prefers-color-scheme: dark) { .mention { color: #e0f1ff; } }
/* 겹침 순서: 릴스 < 게시물 모달 < 스토리 < 설정 모달 */
#reels-viewer { z-index: 200; }
#post-modal { z-index: 220; }
#story-viewer { z-index: 240; }
.ph-avatar:disabled { cursor: default; }
