// ── 편집 3-column 레이아웃 (rank-config__layout 패턴) ──
.crew-widget-layout {
	display: grid;
	grid-template-columns: minmax(0, 500px) auto 1fr;
	gap: 24px;
	align-items: start;
}

// ── 좌측 패널 (미리보기, sticky) ──
.crew-widget-preview {
	position: sticky;
	top: 16px;
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;

	&__widget {
		border: 1px solid hsl(var(--border));
		border-radius: var(--radius);
		overflow: hidden;
	}

	&__widget-label {
		padding: 8px 14px;
		font-size: 0.8125rem;
		font-weight: 500;
		color: hsl(var(--muted));
		background: #0e0e1a;
	}

	&__widget-body {
		padding: 16px;
		min-height: 200px;

		&--basic { background: #1a1a2e; }
		&--dark { background: #0a0a14; }
		&--minimal { background: #222; }
	}

	// ── 위젯 제목 ──
	&__title {
		text-align: center;
		font-weight: 700;
		font-size: 18px;
		margin-bottom: 12px;
		color: #fff;
		text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
	}

	// ── 컬럼 헤더 ──
	&__columns {
		display: flex;
		align-items: center;
		gap: 8px;
		padding: 6px 12px;
		margin-bottom: 6px;
		border-bottom: 1px solid rgba(255, 255, 255, 0.15);
		font-size: 0.6875rem;
		font-weight: 500;
		color: rgba(255, 255, 255, 0.5);
		letter-spacing: 0.03em;
	}

	&__col-rank { width: 28px; text-align: center; flex-shrink: 0; }
	&__col-icon { width: 28px; flex-shrink: 0; }
	&__col-name { flex: 1; min-width: 0; }
	&__col-rate { width: 50px; text-align: right; flex-shrink: 0; }
	&__col-amount { width: 70px; text-align: right; flex-shrink: 0; }
	&__col-count { width: 40px; text-align: right; flex-shrink: 0; }

	// ── 순위 리스트 ──
	&__list {
		display: flex;
		flex-direction: column;
		gap: 6px;
	}

	&__item {
		display: flex;
		align-items: center;
		gap: 8px;
		padding: 8px 12px;
		border-radius: 8px;
		background: rgba(255, 255, 255, 0.08);

		&--1 { background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05)); }
		&--2 { background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(192, 192, 192, 0.05)); }
		&--3 { background: linear-gradient(135deg, rgba(205, 127, 50, 0.15), rgba(205, 127, 50, 0.05)); }
	}

	// ── 순위 배지 ──
	&__badge {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 28px;
		height: 28px;
		border-radius: 50%;
		font-size: 14px;
		font-weight: 800;
		flex-shrink: 0;

		&--1 { background: #FFD700; color: #000; }
		&--2 { background: #C0C0C0; color: #000; }
		&--3 { background: #CD7F32; color: #fff; }
		&--default { background: #555; color: #fff; }
	}

	// ── 크루원 아이콘 ──
	&__member-icon {
		width: 28px;
		height: 28px;
		border-radius: 50%;
		background: #444;
		flex-shrink: 0;
		border: 1px solid rgba(255, 255, 255, 0.15);
	}

	// ── 이름 ──
	&__name {
		flex: 1;
		font-weight: 600;
		color: #fff;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	// ── 기여도 ──
	&__rate {
		width: 50px;
		text-align: right;
		flex-shrink: 0;
		font-size: 0.85em;
		color: #A0D2FF;
		white-space: nowrap;
	}

	// ── 후원 금액 ──
	&__amount {
		width: 70px;
		text-align: right;
		flex-shrink: 0;
		font-weight: 700;
		color: #FF6B35;
		font-size: 0.85em;
		white-space: nowrap;
	}

	// ── 후원 건수 ──
	&__count {
		width: 40px;
		text-align: right;
		flex-shrink: 0;
		font-size: 0.8em;
		color: #aaa;
		white-space: nowrap;
	}
}

// ── 우측 패널 (폼) ──
.crew-widget-form {
	display: flex;
	flex-direction: column;
	gap: 0;

	// ── 섹션 (details 기반, 좌측 제목 / 우측 입력 그리드) ──
	&__section {
		display: grid;
		grid-template-columns: 140px 1fr;
		gap: 24px;
		padding: 24px 0;
		border-bottom: 1px solid hsl(var(--border));

		&:first-of-type {
			padding-top: 0;
		}

		// details 마커 숨김
		&::-webkit-details-marker {
			display: none;
		}
	}

	&__section-title {
		font-size: 0.875rem;
		font-weight: 600;
		color: hsl(var(--foreground));
		padding-top: 2px;
		margin: 0;
		cursor: pointer;
		user-select: none;
		list-style: none;

		&::-webkit-details-marker {
			display: none;
		}

		&::before {
			content: '▸';
			display: inline-block;
			font-size: 0.7rem;
			margin-right: 6px;
			transition: transform 0.15s;
		}

		&:hover {
			color: hsl(var(--foreground) / 0.7);
		}
	}

	// 열린 상태: 화살표 회전
	&__section[open] > .crew-widget-form__section-title::before {
		transform: rotate(90deg);
	}

	&__section-body {
		display: flex;
		flex-direction: column;
		gap: 17px;
		max-width: 520px;
	}

	// ── 필드 행 (2-column 그리드) ──
	&__row {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 10px;

		@media (max-width: 640px) {
			grid-template-columns: 1fr;
		}
	}

	// ── 개별 필드 ──
	&__field {
		display: flex;
		flex-direction: column;
		gap: 6px;
	}

	&__field-label {
		font-size: 0.875rem;
		font-weight: 500;
		color: hsl(var(--foreground));
	}

	&__input {
		padding: 8px 12px;
		border: 1px solid hsl(var(--border));
		border-radius: calc(var(--radius) - 2px);
		background: hsl(var(--background));
		color: hsl(var(--foreground));
		font-size: 0.875rem;
		width: 100%;

		&::placeholder {
			color: hsl(var(--muted-foreground));
		}

		&--color-text {
			flex: 1;
			min-width: 0;
			font-family: monospace;
		}
	}

	&__select {
		padding: 8px 12px;
		border: 1px solid hsl(var(--border));
		border-radius: calc(var(--radius) - 2px);
		background: hsl(var(--background));
		color: hsl(var(--foreground));
		font-size: 0.875rem;
		width: 100%;
		cursor: pointer;
	}

	// ── 색상 선택 필드 ──
	&__color-field {
		display: flex;
		align-items: center;
		gap: 8px;
	}

	&__color-picker {
		width: 36px;
		height: 36px;
		border: 1px solid hsl(var(--border));
		border-radius: calc(var(--radius) - 2px);
		background: none;
		cursor: pointer;
		padding: 2px;
		flex-shrink: 0;

		&::-webkit-color-swatch-wrapper {
			padding: 0;
		}

		&::-webkit-color-swatch {
			border: none;
			border-radius: 2px;
		}

		&::-moz-color-swatch {
			border: none;
			border-radius: 2px;
		}
	}

	// ── 체크박스 행 ──
	&__checkbox-label {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		font-size: 0.875rem;
		color: hsl(var(--foreground));
		cursor: pointer;
	}

	// ── 순위별 폰트 접이식 (details 내부) ──
	&__details {
		border: 1px solid hsl(var(--border));
		border-radius: calc(var(--radius) - 2px);
		overflow: hidden;

		&[open] > .crew-widget-form__details-summary {
			border-bottom: 1px solid hsl(var(--border));
		}
	}

	&__details-summary {
		padding: 10px 14px;
		font-size: 0.8125rem;
		font-weight: 500;
		color: hsl(var(--foreground));
		cursor: pointer;
		user-select: none;
		list-style: none;
		display: flex;
		align-items: center;
		gap: 6px;
		transition: background-color 0.15s;

		&:hover {
			background: hsl(var(--accent) / 0.5);
		}

		&::before {
			content: '▸';
			font-size: 0.75rem;
			transition: transform 0.15s;
		}

		&::-webkit-details-marker {
			display: none;
		}
	}

	&__details[open] > .crew-widget-form__details-summary::before {
		transform: rotate(90deg);
	}

	&__details-body {
		display: flex;
		flex-direction: column;
		gap: 14px;
		padding: 14px;
	}

	// ── 버튼 ──
	&__btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		padding: 8px 20px;
		border: 1px solid hsl(var(--border));
		border-radius: calc(var(--radius) - 2px);
		font-size: 0.875rem;
		font-weight: 500;
		cursor: pointer;
		background: hsl(var(--background));
		color: hsl(var(--foreground));
		transition: background-color 0.15s;

		&:hover:not(:disabled) {
			background: hsl(var(--accent));
		}

		&:disabled {
			opacity: 0.5;
			cursor: not-allowed;
		}

		&--primary {
			background: hsl(var(--primary));
			color: hsl(var(--primary-foreground));
			border-color: hsl(var(--primary));

			&:hover:not(:disabled) {
				background: hsl(var(--primary) / 0.9);
			}
		}
	}

	// ── 하단 버튼 ──
	&__footer {
		display: flex;
		gap: 8px;
		justify-content: center;
		padding-top: 20px;
		margin-top: 4px;
	}
}

// ── 반응형 ──
@media (max-width: 1380px) {
	.crew-widget-form {
		&__section {
			grid-template-columns: 1fr;
			gap: 5px;
		}

		&__section-title {
			margin-bottom: 9px;
		}
	}
}

@media (max-width: 1120px) {
	.crew-widget-layout {
		grid-template-columns: minmax(130px, auto) auto 3fr;
	}
}

@media (max-width: 768px) {
	.crew-widget-layout {
		grid-template-columns: 1fr;
	}

	.crew-widget-preview {
		position: static;
		max-height: none;
	}

	.crew-widget-form {
		&__section {
			grid-template-columns: 1fr;
			gap: 8px;
		}

		&__section-title {
			margin-bottom: 12px;
		}

		&__section-body {
			max-width: none;
		}

		&__row {
			grid-template-columns: 1fr;
		}
	}
}