.top {
	position: sticky;
	top: 0;
	z-index: 50;
	height: var(--top);
	background: var(--page);
	background: color-mix(in srgb, var(--page) 86%, transparent);
	backdrop-filter: saturate(180%) blur(14px);
	-webkit-backdrop-filter: saturate(180%) blur(14px);
	border-bottom: 1px solid var(--line);
}

.top .wrap { display: flex; align-items: center; gap: 12px; height: 100%; }

.brand { flex: 0 0 auto; line-height: 0; }
.brand .logo { height: 42px; width: auto; display: block; }

.hauth { margin-left: auto; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }

.hbtn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 34px;
	padding: 0 14px;
	border: 1px solid var(--ink);
	border-radius: var(--r1);
	background: var(--ink);
	color: var(--on-ink);
	font-size: 13.5px;
	font-weight: 700;
	white-space: nowrap;
	transition: background .13s ease, border-color .13s ease;
}

.hbtn:hover { background: var(--ink-soft); border-color: var(--ink-soft); color: var(--on-ink); }

.hbtn-ghost { background: transparent; border-color: var(--line-hard); color: var(--ink); }
.hbtn-ghost:hover { background: var(--face-2); border-color: var(--line-hard); color: var(--ink); }

.hauth .who { display: inline-flex; align-items: center; height: 34px; gap: 8px; color: var(--ink); }
.hauth .who b { font-size: 13.5px; font-weight: 700; }
.hauth .who:hover { color: var(--ink); }
.hauth .who:hover b { text-decoration: underline; }

.hauth .ava {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: linear-gradient(135deg, #fa0188, #f70126);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
}

.theme {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: var(--r1);
	background: var(--face);
	color: var(--dim);
	line-height: 0;
	transition: color .13s ease, background .13s ease, border-color .13s ease;
}

.theme:hover { color: var(--ink); background: var(--face-2); border-color: var(--line-hard); }
.theme .moon { display: none; }

:root[data-theme=dark] .theme .moon { display: block; }
:root[data-theme=dark] .theme .sun { display: none; }

@media (prefers-color-scheme: dark) {
	:root:not([data-theme=light]) .theme .moon { display: block; }
	:root:not([data-theme=light]) .theme .sun { display: none; }
}

.chips {
	position: sticky;
	top: var(--top);
	z-index: 40;
	background: var(--body);
	background: color-mix(in srgb, var(--body) 88%, transparent);
	backdrop-filter: saturate(180%) blur(14px);
	-webkit-backdrop-filter: saturate(180%) blur(14px);
	border-bottom: 1px solid var(--line);
}

.chips .wrap { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.chips .wrap::-webkit-scrollbar { display: none; }

.chips a {
	position: relative;
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	height: 44px;
	padding: 0 14px;
	color: var(--dim);
	font-size: 14.5px;
	font-weight: 600;
	white-space: nowrap;
	transition: color .13s ease;
}

.chips a::after {
	content: "";
	position: absolute;
	left: 12px;
	right: 12px;
	bottom: -1px;
	height: 2px;
	border-radius: 2px 2px 0 0;
	background: transparent;
	transition: background .13s ease;
}

.chips a:hover { color: var(--ink); }
.chips a.on { color: var(--ink); font-weight: 700; }
.chips a.on::after { background: var(--brand); }

.shell { padding: 20px 0 44px; }

.shell .wrap {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--rail);
	align-items: start;
	gap: var(--gap);
}

.content { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

/* 로그인·가입·찾기처럼 좁은 폼 하나뿐인 화면은 사이드바를 접고 가운데로 모은다 */
.shell .wrap:has(> .content > .form-narrow:only-child) { max-width: 760px; grid-template-columns: minmax(0, 1fr); }
.shell .wrap:has(> .content > .form-narrow:only-child) .side { display: none; }

.side { position: sticky; top: calc(var(--top) + 58px); display: flex; flex-direction: column; gap: 14px; }

.side section {
	background: var(--page);
	border: 1px solid var(--line);
	border-radius: var(--r2);
	box-shadow: var(--sh1);
	overflow: hidden;
}

.side h2 {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 13px 16px 11px;
	font-size: 14.5px;
	color: var(--ink);
}

.side h2::before {
	content: "";
	width: 3px;
	height: 13px;
	border-radius: 2px;
	background: var(--brand);
}

.side ul { padding: 0 0 6px; }

.side li a {
	display: flex;
	align-items: baseline;
	gap: 9px;
	min-width: 0;
	padding: 8px 16px;
	color: var(--ink-soft);
	font-size: 13.5px;
	line-height: 1.45;
}

.side li a:hover { background: var(--face); color: var(--ink); }
.side li a .t { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side li a .c { flex: 0 0 auto; color: var(--brand-text); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.side li a .d { flex: 0 0 auto; color: var(--dim-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.side li a .sub { display: block; margin-top: 2px; color: var(--dim); font-size: 12px; }
.side li a .stack { min-width: 0; flex: 1 1 auto; }
.side li a .stack .t { display: block; }

.side .no {
	flex: 0 0 16px;
	font-size: 12.5px;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	color: var(--dim-soft);
	text-align: center;
}

.side .rank li:nth-child(1) .no { color: var(--gold); }
.side .rank li:nth-child(2) .no { color: var(--silver); }
.side .rank li:nth-child(3) .no { color: var(--bronze); }

.side .none { padding: 18px 16px; color: var(--dim); font-size: 13.5px; }

.foot { border-top: 1px solid var(--line); background: var(--page); }

.foot .band .wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0 4px;
	padding-top: 10px;
	padding-bottom: 4px;
}

.foot .band a {
	display: inline-flex;
	align-items: center;
	min-height: 34px;
	padding: 0 9px;
	color: var(--dim);
	font-size: 13px;
}

.foot .band a:hover { color: var(--ink); }

.foot .info { padding-top: 6px; padding-bottom: 28px; text-align: center; color: var(--dim-soft); font-size: 12.5px; }
.foot .info .name { color: var(--dim); font-weight: 700; margin-bottom: 3px; font-size: 13px; }

.fab {
	display: none;
	position: fixed;
	right: 16px;
	bottom: calc(18px + env(safe-area-inset-bottom));
	z-index: 55;
	align-items: center;
	gap: 6px;
	height: 46px;
	padding: 0 18px;
	border-radius: 999px;
	background: var(--brand);
	color: var(--on-brand);
	font-size: 14.5px;
	font-weight: 700;
	box-shadow: var(--sh3);
}

.fab:hover { background: var(--brand-strong); color: var(--on-brand); }
.fab svg { display: block; }

@media (max-width: 1040px) {
	:root { --rail: 264px; }
}

@media (max-width: 940px) {
	.shell { padding: 14px 0 30px; }
	.shell .wrap { display: block; }
	.side { position: static; margin-top: 14px; }
	.fab { display: flex; }
}

@media (max-width: 720px) {
	.brand .logo { height: 36px; }
	/* 회원가입은 로그인 화면에, 관리자·로그아웃은 내 정보에 있으므로 좁은 화면에서는 접는다 */
	.hbtn-ghost { display: none; }
	.hauth { gap: 6px; }
	.hbtn { height: 32px; padding: 0 11px; font-size: 13px; }
	.hauth .who b { max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.chips a { height: 42px; padding: 0 12px; font-size: 14px; }
}

@media (pointer: coarse) {
	.side li a { padding: 11px 16px; }
	.foot .band a { min-height: 40px; }
}

.force-mobile .wrap { max-width: 480px; }
.force-mobile .hbtn-ghost { display: none; }
.force-mobile .brand .logo { height: 36px; }
.force-mobile .shell .wrap { display: block; }
.force-mobile .side { position: static; margin-top: 14px; }
.force-mobile .fab { display: flex; }
